[ABE.pm] Seeking comments re OOP (Continuing my series of dumb questions)

Randy Kramer rhkramer at gmail.com
Thu Dec 30 09:54:55 CST 2004


On Thu, 30 Dec 2004 10:40:21 -0500, Ricardo SIGNES
<rjbs-perl-abe at lists.manxome.org> wrote:
> * Randy Kramer <rhkramer at gmail.com> [2004-12-30T10:13:49]
> AccountLedger.accounts.sort { |a,b| a.balance <=> b.balance }.each { |act|
>   puts act.name
> }
> 
> ^^ List all accounts in order of balance.  I think Ruby 1.8's sort_by
> can be used, here, though I'm not very intimate with it.
> 
> AccountLedger.accounts.sort_by { |a| a.balance }.each { |act|
> 
> should be able to replace the above first line.

Thanks!  (I'm sure that will make sense to me once I study it (and
Ruby) a little more.  (Clearly, it's not as simple as
AccountLedger.accounts.sort { puts act.name} which is a useful start.)

regards,
Randy Kramer


More information about the ABE-pm mailing list