hoodwink.d enhanced
RSS
2.0
XHTML
1.0

RedHanded

(String < Enumerable).nil? #

by why in inspect

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.)

said on

So does "one\ntwo".to_a still return ["one\n", "two"], or did String’s to_a come from Enumerable?

said on

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.

said on

Hooray!

said on

Didn’t you mean idempotent string splat?

said on

impotent seems appropriate!

said on

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.

said on

Hmm. Well, at least it’ll stop me expecting ‘string’.each to yield each character (well, modulo Unicode support) in turn…

said on DD Mon YYYY at HH:MM

* do fancy stuff in your comment.

PREVIEW PANE