%w(foo bar)
is a shortcut for ["foo", "bar"]
. Meaning it’s a notation to write an array of strings separated by spaces instead of commas and without quotes around them. You can find a list of ways of writing literals in zenspider’s quickref.
More Related Contents:
- Very Basic Ruby puts and gets
- How do I pick randomly from an array?
- How to check if a value exists in an array in Ruby
- Ruby array access 2 consecutive(chained) elements at a time
- How to find and return a duplicate value in array
- Ruby function to remove all white spaces?
- How to split (chunk) a Ruby array into parts of X elements? [duplicate]
- How to find an item in array which has the most occurrences [duplicate]
- How to count duplicate elements in a Ruby array
- Creating matrix with `Array.new(n, Array.new)`
- Create two-dimensional arrays and access sub-arrays in Ruby
- Backslashes in single quoted strings vs. double quoted strings
- Extract a substring from a string in Ruby using a regular expression
- Which style of Ruby string quoting do you favour?
- Ruby method Array#
- Need to split arrays to sub arrays of specified size in Ruby [duplicate]
- String interpolation in Ruby doesn’t work?
- Ruby – Difference between Array#
- Read binary file as string in Ruby
- Convert array of 2-element arrays into a hash, where duplicate keys append additional values
- Why do two strings separated by space concatenate in Ruby?
- How to sort an array in Ruby to a particular order?
- Convert unicode codepoint to string character in Ruby
- Ruby: Merging variables in to a string
- Split string by multiple delimiters
- Ruby: filter array by regex?
- Ruby array subtraction without removing items more than once
- Where is it legal to use ruby splat operator?
- What is the best way to split a string to get all the substrings by Ruby?
- How do I remove blank elements from an array?