From: Robert Dober Date: 2010-09-30T17:29:17+09:00 Subject: Re: The beauty of Ruby through examples On Thu, Sep 30, 2010 at 9:35 AM, F. Senault wrote: > Le 29 septembre à 21:26, F. Senault a écrit : > > And I forgot a simple, classic, one : > > def factorial(n) >  (1..n).inject(1) { |p, f| p * f } > end > > def factorial(n) >  (1..n).inject(1, :*) > end > > (I don't like much the second one, it's a bit less legible.) You see, that depends, it is more readanble to me. Probably totally depends on the context. For folks coming from functional languages the simple fact of using inject's synonym might also add to readability (1..n).reduce 1, :* In conclusion I prefer naming things, but the downside is that one has to communicate names and agree about them. The explicit code block does not have that disadvantage. However it does not trigger the information in the brain as quickly as names do, once they are understood. This might indeed be one of the forces and beauties of Ruby and it might be a good idea for OP to show that to his audience. Cheers Robert -- The best way to predict the future is to invent it. -- Alan Kay