J
Just Another Victim of the Ambient Morality
I just wrote some code that shouldn't have worked, in my estimation, but
it did, anyway. While this was a pleasant surprise, I prefer to understand
why things don't work than to wonder why they did work...
What was happening is this situation, here:
if false
variable = true
end
if variable
#do something
end
To my surprise, this is okay! Even though the code in the first
if-clause doesn't get run, the variable in the clause gets created,
anyway...
Now, I'm pretty sure this is expected behaviour. What I'm wondering is
how people feel about this. This behaviour makes me feel uneasy. If I'm
using a variable that hasn't been deliberately created then I'd rather have
the interpreter complain that I haven't created the variable, as planned,
than to be confused as to why my variable is nil.
I'm very interested to hear other opinions on the subect. Anyone care
to comment?
Thank you...
it did, anyway. While this was a pleasant surprise, I prefer to understand
why things don't work than to wonder why they did work...
What was happening is this situation, here:
if false
variable = true
end
if variable
#do something
end
To my surprise, this is okay! Even though the code in the first
if-clause doesn't get run, the variable in the clause gets created,
anyway...
Now, I'm pretty sure this is expected behaviour. What I'm wondering is
how people feel about this. This behaviour makes me feel uneasy. If I'm
using a variable that hasn't been deliberately created then I'd rather have
the interpreter complain that I haven't created the variable, as planned,
than to be confused as to why my variable is nil.
I'm very interested to hear other opinions on the subect. Anyone care
to comment?
Thank you...