the following program for showing Variable / Method Ambiguity
def a
print "Function 'a' called\n"
99
end
for i in 1..2
if i == 2
print "a=", a, "\n"
else
a = 1
print "a=", a, "\n"
end
end
will produce the result:
a=1
Function 'a' called
a=99
(as described in the PickAx2 book, p. 329)
So at first I thought a Ruby program is interpreted? If interpreted,
then the interpreter will see the "a = 1" at first as treat "a" as a
variable, and then the second time it sees "a", the interpreter should
treat it as a variable again, not as a method. So does that mean a
Ruby program is not interpreted but compiled into some bytecode first?
But then, sometimes I run a Ruby program and then it can run all the way
until it see an "undefined local variable"... so that means it probably
is not compiled... or else it would have stopped without running
anything at all.
So is a Ruby program interpreted or compiled?
···
--
Posted via http://www.ruby-forum.com/.