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.
Written by Luca Guidi
Related protips
3 Responses
It looks like the Ruby syntax here is broken.
over 1 year ago
·
wat
over 1 year ago
·
Correct syntax highlight for this protip:
https://gist.github.com/jodosha/7410007
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Related Tags
#ruby
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#