From: Koncept [mailto:user@unknown.invalid]
In article 200402120054.23296.martin@zsdfherg.com, Martin Hartirb(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
=> ArrayThis 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:
- Suggestion to use gsub over sub. I assume that gsub is global?
You assume correctly. Either will work in your particular case.
- 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/
···
-----Original Message-----
martin@zsdfherg.com wrote: