http://www.voidspace.org.uk/python/weblog/arch_d7_2008_03_22.shtml#e954
Nice example of what you can do with generators. Is this sort of thing
doable efficiently in 1.9?
martin
http://www.voidspace.org.uk/python/weblog/arch_d7_2008_03_22.shtml#e954
Nice example of what you can do with generators. Is this sort of thing
doable efficiently in 1.9?
martin
On Mar 27, 2008, at 1:20 PM, Martin DeMello wrote:
http://www.voidspace.org.uk/python/weblog/
arch_d7_2008_03_22.shtml#e954Nice example of what you can do with generators. Is this sort of thing
doable efficiently in 1.9?
Don’t know if this meets the criteria, but
http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html
http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html
Cheers
Dave
On Thu, Mar 27, 2008 at 11:33 AM, Dave T. [email protected] wrote:
Don’t know if this meets the criteria, but
http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html
http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html
Yes, exactly what I had in mind. Very nice.
martin
On Thu, Mar 27, 2008 at 11:33 AM, Dave T. [email protected] wrote:
http://pragdave.blogs.pragprog.com/pragdave/2007/12/pipelines-using.html
http://pragdave.blogs.pragprog.com/pragdave/2008/01/pipelines-using.html
Tangentially, why did the trick of defining methods with the same name
as classes, to delegate to Class.new, fall out of favour?
tripler = Transformer.new {|val| val * 3}
would read more nicely as
tripler = Transformer {|val| val * 3}
with def Transformer(x); Transformer.new(x); end
I remember it being a commoner practice a few years ago.
martin
On Mar 27, 12:20 pm, “Martin DeMello” [email protected] wrote:
http://www.voidspace.org.uk/python/weblog/arch_d7_2008_03_22.shtml#e954
Nice example of what you can do with generators. Is this sort of thing
doable efficiently in 1.9?
some_date.filter1.filter2.action
What is the advantage of data filters over method chaining in
practical terms? What am I missing?
Regards,
Dan
Daniel B. wrote:
practical terms? What am I missing?
Apparently, PragDave’s filters read one entry at a time, on demand (like
unix pipes). Method chaining has to build a complete collection for each
step.
On Thu, Mar 27, 2008 at 6:51 PM, Martin DeMello
[email protected] wrote:
with def Transformer(x); Transformer.new(x); end
I remember it being a commoner practice a few years ago.
martin
Some of us oldies still use it. But I seem to remember some people
objected last time I suggested it (ruby-talk[160664]).
Regards,
Sean
Martin DeMello wrote:
tripler = Transformer {|val| val * 3}with def Transformer(x); Transformer.new(x); end
I remember it being a commoner practice a few years ago.
martin
It looks like a typo when there is no method name after (what looks
like) a constant name. There’s also the cognitive load of deciding
whether “Transformer.meth” is “send :meth to the result of method
Transformer()” or “send :meth to the value of constant Transformer”. My
brain knows it is the latter, but my eyes don’t.
class T
def self.meth; “T.meth” end
def meth; “T#meth” end
end
def T; T.new; end
p T.meth
p T().meth
p T.new.meth
Quick, which one(s) are calling the class method, T#meth. But maybe
that’s just me.
As long as we’re playing in the global space, I’d define a lower case
method, #transformer. Saves a keystroke, too.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs