sk13pa
Last Updated: February 25, 2016
·
892
· 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

10654

It looks like the Ruby syntax here is broken.

over 1 year ago ·
10741

wat

over 1 year ago ·
10764

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

over 1 year ago ·