Le samedi 24 mars 2007 00:20, Paul Stickney a crit:
> require 'yaml'
> some_obj = YAML.load(gets.chomp) rescue nil
>
> If your input is "[1,2,3,4]" then it will return an array with 4
> elements of 1, 2, 3 and 4, respectively. Of course, you could input
> any valid (or not so valid) YAML and get back a String or Hash or....
> The rescue is just to ensure we get a nil instead of an error on
> really bad input.
>
> Enjoy,
> Paul

I didn't know that yaml can contain bracketed arrays like this. However, your 
code seems to work only if there are spaces along with the comas :

irb(main):012:0> YAML.load("[1, 2, 3]")
=> [1, 2, 3]

but

irb(main):013:0> YAML.load("[1,2,3]")
=> [123]


-- 
Olivier Renaud