From: Simon Strandgaard Date: 2004-08-06T16:07:00+09:00 Subject: Re: %w for symbols On Friday 06 August 2004 09:00, Caio Chassot wrote: > Is there any similar notation to %w[ word word2 word3 ] that returns an > array of symbols instead of strings? > > If not, are there any plans for it in future ruby? Is it a good idea > anyway? > > (Maybe that's a good example of where we could use macros?) %w(a b c).map{|i|i.to_sym} #=> [:a, :b, :c] If that isn't short enough.. then you may want to do irb(main):001:0> class Array; def to_sym; self.map{|i|i.to_sym}; end; end => nil irb(main):001:0> %w(a b c).to_sym => [:a, :b, :c] IMHO I don't think a literal for easier making array of symbols is needed. -- Simon Strandgaard