On 10/20/05, Anders H=F6ckersten <> wrote:
> Me and a friend realised earlier today that this is actually a legal
> Ruby program:
> foo(def foo(a=3Dnil)
> puts "hello"
> end)
> foo
>
> The fact that this works seems to be a side effect of Ruby's semantics
> rather than an intended feature, but maybe it's actually useful to be
> able to do this? I can't think of any (practical) use of it -
> suggestions are welcome.
>
> Regards,
> Anders
>
That's pretty interesting. It makes for some interesting recursion too
irb(main):021:0> foo(def foo(a=3Dnil)
irb(main):022:2> puts a
irb(main):023:2> a +=3D 1 if not a.nil?
irb(main):024:2> return a
irb(main):025:2> end)
nil
=3D> nil
irb(main):026:0> foo(foo(foo(foo(foo(foo(1))))))
1
2
3
4
5
6
=3D> 7