L
levilista
###########################
y=5
print "y: " + y.to_s + "\n"
text_at_the_end = lambda do |y|
print y + " text at the end\n"
end
print "y: " + y.to_s + "\n"
def oneparam
yield("oneparam")
end
oneparam(&text_at_the_end)
print "y: " + y + "\n"
########################
It gives the following output:
y: 5
y: 5
oneparam text at the end
y: oneparam
Is this a bug? Shouldn't "y" be in a local scope in "text_at_the_end"?
I just downloadad Ruby yesterday:
Ruby Version 1.8.6
Installer Version 186-26
y=5
print "y: " + y.to_s + "\n"
text_at_the_end = lambda do |y|
print y + " text at the end\n"
end
print "y: " + y.to_s + "\n"
def oneparam
yield("oneparam")
end
oneparam(&text_at_the_end)
print "y: " + y + "\n"
########################
It gives the following output:
y: 5
y: 5
oneparam text at the end
y: oneparam
Is this a bug? Shouldn't "y" be in a local scope in "text_at_the_end"?
I just downloadad Ruby yesterday:
Ruby Version 1.8.6
Installer Version 186-26