(String < Enumerable).nil? #
So, it sounds like the 1.9 series will remove Enumerable
from String
’s ancestry, in favor of String#lines
. All string iteration casts to an Array. Maybe I’m getting my hopes up, but all these string changes seem like portents of Unicode Times.
>> str = "pony\nwagon\nstungun\n" => "pony\nwagon\nstungun\n" >> str.max NoMethodError: undefined method `max' for "pony\nwagon\nstungun\n":String from (irb):2:in `Kernel#binding' >> str.lines.max => "wagon\n"
Makes sense. Anyone else mourning the impotent string splat?
>> utilities = *str => ["pony\nwagon\nstungun\n"]
Like a little rotary saw whose tooth got stuck. (from matz and patch.)
sam
So does
"one\ntwo".to_a
still return["one\n", "two"]
, or did String’sto_a
come from Enumerable?Daniel Berger
Removing Enumerable makes sense – there were only two methods most people cared about anyway – ‘to_a’ and ‘each’. The latter is far more important from an interface perspective IMO .
I’m curious how both of these are handled.
chris2
Hooray!
damien
Didn’t you mean idempotent string splat?
wog
impotent seems appropriate!
zem
Brilliant! One of the early things that bit me in Ruby was the fact that Strings broke the def foo(arg); case arg; when Enumerable; arg.each {|i| foo(i)} ... pattern.
mathie
Hmm. Well, at least it’ll stop me expecting ‘string’.each to yield each character (well, modulo Unicode support) in turn…