From: Trans Date: 2006-12-07T07:57:16+09:00 Subject: Re: invasive parameters as method mode variables Robert Klemme wrote: > On 06.12.2006 18:37, Trans wrote: > > ara.t.howard@noaa.gov wrote: > > > >> method + state => object > > I would have put it differently: command pattern. Your method seems > pretty complex so you can change it into a command object. If the > problem at hand is complex then it probably needs a complex solution. > But I would not go down the metaprogramming route. > > > 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) > => # 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.