0

Possible Duplicate:
How do I convert a Ruby string with brackets to an array?

In ruby, how to transform a string to an array when this string looks-like an array declaration? Is there an equivalent of "eval" methods? I would like to avoid the split method is this case.

Eg.

myString = "[['joey','male','[email protected]],['jenny','female','[email protected]']]"

1

1 Answer 1

0

eval would do it. However I would recommend using something like JSON.parse if the data is coming from an untrusted source (i.e. the Internet).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.