Afficher un message
Vieux 12/03/2008, 04h50   #1
Clifford Heath
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut "".to_a isn't consistent with "string".to_a

I've just been tripped up by this behaviour, which I haven't
seen documented anywhere:

"hello".to_a #=> ["hello"]
"".to_a #=> []

Why does an empty string get omitted from the array?
Why doesn't Enumerable#to_a document this behaviour of strings?
This is completely broken (Ruby 1.8.6)

This affected me in a call to send() using a splat - it always
works ok except when the parameter list is an empty string :-(.

Clifford Heath.
  Réponse avec citation
 
Page generated in 0,04172 seconds with 9 queries