Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there way to create a symbol's array like string with %w?

Tags:

string

ruby

I can create a array of strings by %w(foo bar). Is there similar way to create a array of symbols?

like image 607
ironsand Avatar asked Mar 27 '14 13:03

ironsand


Video Answer


1 Answers

Just do as below :

%i(foo bar)

It is available since Ruby2.0.0.

Check out the their official News

Added %i and %I for symbol list creation (similar to %w and %W).

like image 64
Arup Rakshit Avatar answered Nov 15 '22 03:11

Arup Rakshit