Array with %w : Array Literal « Array « Ruby






Array with %w


words = %w[this is a test]  # Same as: ['this', 'is', 'a', 'test']
open = %w| ( [ { < |        # Same as: ['(', '[', '{', '<']
white = %W(\s \t \r \n)     # Same as: ["\s", "\t", "\r", "\n"]

 

Related examples in the same category

1.Several Array literals