instance, class and global variables in strings
the curly braces for instance, class and global variables are optional for string interpolation:
local = 'pie'
@instance = 'makes'
@@class = 'me'
$global = 'happy'
# note the missing curly braces
puts "#{local} #@instance #@@class #$global"
=> pie makes me happy
Written by Gino Lucero
Related protips
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#