From: [email protected] [mailto:[email protected]]
Sent: Wednesday, December 06, 2006 1:15 PM
implied by those three separate method calls.
employees.select{|e| (e.name == ‘John’) & (e.salary > 50)}.sort_by{|e|salary is greater than 50. Return that result set. That’s a discrete
OK, I agree.
I’ve came to proposed version in two stages:
- was excited about idea on “list comprehension as database request”
ideom - was translated the “common” list comprehension to Ruby-style one.
Hence the controversial result.
Idea I ruled by was shown in Links[1] language overview and looks like
where (prefix != “”)
take(10,
for (var w ← wordlist)
where (w.word ~ /{prefix}.*/)
orderby (w.word)
[w]
)
Which, in turn, looks like “only one” method call. Where ruby’s
equivalent
is several calls.
So, for consistency, the idea must look like you’ve shown:
employees.select{|e| (e.name == ‘John’) & (e.salary > 50)}.sort_by{|e|
e.age}[2…10].run
or, may be
employees.do{ select{|e| (e.name == ‘John’) & (e.salary >
50)}.sort_by{|e|
e.age}[2…10] }
Hmm. I see, while I’m writing this, you have already posted the nearly
same
![]()
V.
