I don't understand #{ }

Hi there,

I'm new to ruby and rails. I'm going through a few tutorials and I got the updated agile book. One thing I keep seeing which hasn't quite been properly explained is something like this:

puts "Hello #{name.capitalize}!"

At one place it stated that the {} merely insert a string into a string - I assume like concatenation. However the # has not been explained. Do the # and {} go together?

Yes, they do go together. It just callse to_s on the result of any ruby code between #{ and }.

-Bill

Pixelmech wrote:

*calls not callseā€¦hit send to fast :slight_smile:

William Pratt wrote:

Ah, gotcha. Thank you!