String Interpolation


#1

Here is my code:

favorite_things = ["Ruby", "espresso", "candy"]

puts "A few of my favorite things:"

favorite_things.each do |thing|
puts "I love #{thing}! "
end

but when I run it, says "Oops, try again. It looks like your code doesn't print out "I love Ruby!""
Anywhere I have gone wrong?


#2

I tried your code and discovered that the extra space after the exclamation mark before the quotation mark gave me same error as yours. Remove that space and it resolves.

See below:

favorite_things = ["Ruby", "espresso", "candy"]

puts "A few of my favorite things:"

favorite_things.each do |thing|
  puts "I love #{thing}!"
end

#3

Yeah, I did that and it worked. Thanks.


#4

You're welcome, @groundzero9999 .

Have fun coding! :slight_smile:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.