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:

explained. Do the # and {} go together?


Sincerely,

William P.

*calls not callse…hit send to fast :slight_smile:

William P. wrote:

the updated agile book. One thing I keep seeing which hasn’t quite


Sincerely,

William P.

On Nov 30, 1:02 pm, William P. [email protected] wrote:

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

Ah, gotcha. Thank you!