Ruby easy arrays
A simple declaration of an array in Ruby for my name ( I'm assuming you are using irb console):
$ name = ["jose", "mariz", "melo", "formiga", "viana"]
=> ["jose", "mariz", "melo", "formiga", "viana"]
That works fine but is a little exhausting, don't you think? Ruby language provide you an easier way to do this, using '%w[]', let's try that:
$ name = %w[jose mariz melo formiga viana]
=> ["jose", "mariz", "melo", "formiga", "viana"]
Happy Hacking!
Written by Mariz Melo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#