Where to use new literal %i on Ruby 2.0.0
A nice place to use this new thing is on attr_accessor and others alike. Here is an example
class A
attr_accessor *%i(foo bar)
end
a = A.new
a.foo = 1
a.foo #=> 1
Written by Ismael Abreu
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#