On Sat, Jul 26, 2008 at 5:53 PM, aidy <aidy.lewis / googlemail.com> wrote:
> On Jul 26, 4:19 pm, Phlip <phlip2... / gmail.com> wrote:
>
>>
>> Ruby expects to assign constants only once. If you called aidy() twice, the
>> constant would re-assign, and it therefor would not be constant.
>>
>
> Excellant explanation.

But not quite correct, constants *can* be reassigned all you get is a warning.
Nevertheless I think it is good semantics to forbid constant
assignments in methods. If for one reason or another
you need such a beast you can still do it of course.

def a x; Object.const_set "A", x end
a 42
p A
a 44 # get a warning
p A

HTH
Robert





-- 
http://ruby-smalltalk.blogspot.com/

There's no one thing that's true. It's all true.
--
Ernest Hemingway