"Jeremy McAnally" <jeremymcanally / gmail.com> wrote on 05/22/2008 05:35:01=20
PM:
> 2008/5/22 Rados=B3aw Bu=B3at <radek.bulat / gmail.com>:
> >
> > This example comes from Ryan Bates railscasts
> > (http://railscasts.com/episodes/108).
> > In Ruby 1.9 it's easier with ->
> >
> > named=5Fscope :recent, ->(time =3D 2.weeks.ago) { {:conditions =3D>
> >   ["released=5Fat > ?", time]} }
>
> Even though I see the usefulness, that's just ugly.

Agreed. If the || issue with lambda was fixed, couldn't that read:

   named=5Fscope :recent, lambda{|time =3D 2.weeks.ago| {:conditions =3D>
     ["released=5Fat > ?", time]} }

There is only a 3-character difference in typing, but if that is too
much, here are a couple 1-character options.

   # Use &func like Perl
   named=5Fscope :recent, &{|time =3D 2.weeks.ago| {:conditions =3D>
     ["released=5Fat > ?", time]} }

   # Use \{}=20
   named=5Fscope :recent, \{|time =3D 2.weeks.ago| {:conditions =3D>
     ["released=5Fat > ?", time]} }
=20
   # Use coupled {{ }}=20
   named=5Fscope :recent, {{|time =3D 2.weeks.ago| {:conditions =3D>
     ["released=5Fat > ?", time]} }}


Nate Wiger
PlayStation