Last night, myself and the local Ruby group started down the path of preparation for the Ruby certification exam (after being inspired by Fabio Kung to go for it). One of the things we covered was here docs, a facility for creating multi-line strings in Ruby. We came across two funky cases (or at least I thought they were funky) that seemed good enough for quiz questions. Given the following here docs, what would you expect to print for the values of v1 & v2:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a, b = 'hey', 'now' | |
v1 = <<Foo.upcase | |
#{a + b} | |
Foo | |
puts v1 | |
v2 = <<'Foo'.upcase | |
#{a + b} | |
Foo | |
puts v2 |