From: David Naseby Date: 2004-02-12T10:34:14+09:00 Subject: Re: (noob) cast string to array? >-----Original Message----- >From: Koncept [mailto:user@unknown.invalid] >In article <200402120054.23296.martin@zsdfherg.com>, Martin Hart > wrote: > >> irb(main):002:0> s = '["a string", "another string"]' >> => "[\"a string\", \"another string\"]" >> irb(main):003:0> array = eval s >> => ["a string", "another string"] >> irb(main):004:0> array.class >> => Array > >This is great! Thanks Martin. Thanks for all the fast responses as well >everybody. Avoid eval!!! >I just wanted to follow up on some of the responses here: > >1) Suggestion to use gsub over sub. I assume that gsub is global? You assume correctly. Either will work in your particular case. >2) what is the "!" responsible for doing? (Remember me = n00b ) Its a hint for a "dangerous" method - generally, one that changes the receiver. It signals to the reader its intent, but syntactically, its just part of the identifier. Its like ? methods should return a bool (eg, x.is_nil? ). David http://homepages.ihug.com.au/~naseby/