From: "David A. Black" Date: 2008-07-29T08:44:27+09:00 Subject: Re: what is %w Hi -- On Tue, 29 Jul 2008, Sam Haskins wrote: > On Jul 28, 2008, at 2:39 PM, David A. Black wrote: > >> Hi -- >> >> On Tue, 29 Jul 2008, Joel Saltzmanjoelh wrote: >> >>> What is the %w used for in ruby? >> >> To create an array of strings: >> >> %w{ one two three } # same as ["one", "two", "three"] >> >> You can use other delimiters, like []. I'm not sure why I've >> gravitated toward curly braces for this. >> > What sort of situations is that syntax useful in? It's very handy for saving typing. It's just faster. Also, if your strings happen to have quotation marks in them, you don't have to escape them. That may not happen every day, and there are other ways to bring that about, but it could be useful. David -- Rails training from David A. Black and Ruby Power and Light: * Advancing With Rails August 18-21 Edison, NJ * Co-taught by D.A. Black and Erik Kastner See http://www.rubypal.com for details and updates!