(I think…)
Having a brain-fade today. Is there a simple ruby equivalent to
perl’s qw() construct? I want, in order to save typing, to convert a
list of non-quoted words like so:
foo bar baz…
into an array of quoted strings: [“foo”, “bar”, “baz”, …]
Perl does this by: @list = qw(foo bar baz …);
this works… list = “foo bar baz”.scan(/\w+/)
as does: list = “foo bar baz”.split(/ /)
but both seem wieldy and heavy-handed.
#2
Is there a way to get matched data into variables without using
matchdata, or perl ugly-variables?
Again, in perl I could do something like:
$_ = “Dec 12”;
(mon, day) = /(\w+) (\d+)/;
Sorry for being so daft…had a long weekend.
···
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com