MenTaLguY
3/1/2006 10:17:00 PM
Quoting Jeff Cohen <cohen.jeff@gmail.com>:
> unknown wrote:
> > Quoting Jeff Cohen <cohen.jeff@gmail.com>:
> >
> > Assignments are legal in most places that => is; would you want
> > to trade one for the other?
> >
> > -mental
>
> Really? This works for me:
>
> h = { 'a' => 5, 'b' => 6 }
>
> but this gives my syntax errors:
>
> h = { 'a' = 5, 'b' = 6 }
Legal, not equivalent.
For example, you can do this:
p { 'a' => k = 5, 'b' => 6 }
p k
which would print:
{"a"=>5, "b"=>6}
5
The arguments to => can be any legal Ruby expressions, including
assignments.
-mental