R
RichardOnRails
The following program:
# K:\Analysis
# TestUndefinedLocalVar_hash.rb
a = []
a << "xyz"
a << hash
a << undefined
crashes on line 8 (a << undefined) rather than on line 7 (which
apparently appends a reference to the undefined "hash" to the array.
What causes this mythical creation of "hash"? Is this behavior
defined anywhere?
If it matters, the following explains how I encountered this problem:
I have a program which had been using a local var named "hash". Use
of that name caused no problem.
However, I decided I should change the value assigned to hash, so I
changed all references to it to "hash_string" ... all but one. I
expected that after I made changes to the way hash_string was
computed, my program would fail when the reference to the now-
undefined hash was encountered. No such luck.
Thanks in Advance,
Richard
# K:\Analysis
# TestUndefinedLocalVar_hash.rb
a = []
a << "xyz"
a << hash
a << undefined
crashes on line 8 (a << undefined) rather than on line 7 (which
apparently appends a reference to the undefined "hash" to the array.
What causes this mythical creation of "hash"? Is this behavior
defined anywhere?
If it matters, the following explains how I encountered this problem:
I have a program which had been using a local var named "hash". Use
of that name caused no problem.
However, I decided I should change the value assigned to hash, so I
changed all references to it to "hash_string" ... all but one. I
expected that after I made changes to the way hash_string was
computed, my program would fail when the reference to the now-
undefined hash was encountered. No such luck.
Thanks in Advance,
Richard