On Mar 27, 12:28 pm, Conrad Taylor <[email protected]> wrote:
> On Fri, Mar 27, 2009 at 2:59 AM, robdoan <[email protected]> wrote:
>
> > As I remember u can not use lambda do do |abc |
> > end
> > U must use : lambda {| abc| }
>
> lambda do |abc|
> ...
> end
>
> is equivalent to
>
> lambda { |abc| ... }
>
> Thus, they are both legal in Ruby 1.8 and 1.9.
>
{} binds more tightly than do..end so you do sometimes need to use ()
to disambiguate, eg
named_scope :foo, lambda { ... }
is ok
but
named_scope :foo, lambda do
...
end
isn't because ruby thinks that this block is for named_scope, not
lambda.
named_scope(:foo, lambda do
...
end)
makes it clear to ruby what to do.
Fred
> -Conrad
>
>
>
> > On Mar 26, 6:16 pm, Fresh Mix <[email protected]>
> > wrote:
> > > I have this problem only if I run Rails by mongrel_cluster.
>
> > > ./script/server works fine.
> > > --
> > > Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---