These e-mails are becoming invasive. take me off of this list.
----- Original Message ----
From: Trans [email protected]
To: ruby-talk ML [email protected]
Sent: Wednesday, December 6, 2006 4:57:16 PM
Subject: Re: invasive parameters as method mode variables
Robert K. wrote:
good point. though it moves me away from the simplicity of single call.
also i wonder about things like String#each. the global default for
separator is not really the ideal implementation, but #each can’t be
made a class.Really?
require ‘enumerator’
=> true
%w{foo bar baz}.to_enum(:each)
=> #Enumerable::Enumerator:0x3a6b00
Sure. But I would think it preferable to just call str.each. Not have
to resort to Enumerators. Doing…
“this is a string”.to_enum(:each, //).select { |c| …
is less efficent and less readable (once you know what $/ is) then
$/ = // ; “this is a string”.select { |c| …
And if we can do it gloablly, which is not ideal, then why not do it
better with a local “method mode variable”?
Of course, I’m still not sure why it’s such a bad idea to allow
Enumberable to pass thru a parameter to #each.
T.