Ruby Shortcuts

You often see the Array shortcut in code…

%w(foo bar sed)  # => ["foo", "bar", "sed"]

…but how many of the other Ruby Shortcuts are you aware of? Personally I knew about half of them.

Tags: , , ,

2 comments

  1. I’m partial to %w[foo bar sed] as the brackets are a bit more array-esque

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>