Last Updated: February 25, 2016
·
1.257K
· jodosha

TIL Ruby variables string interpolation

Aside from the classic variables string interpolation (#{ var }), Ruby offers a slightly different syntax:

@planet = 'World'
puts "Hello, #@planet!" # => "Hello, World!"

It works also with class (@@var) and global ($var) variables.

3 Responses
Add your response

It looks like the Ruby syntax here is broken.

over 1 year ago ·

Correct syntax highlight for this protip:
https://gist.github.com/jodosha/7410007

over 1 year ago ·