[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Why does this work?
- From: Steve Litt <slitt@...>
- Date: Thu, 3 Feb 2011 22:30:20 -0500
Hi all,
Why does this work?
#!/usr/bin/lua
do
local oldprint = print
print = function(str)
oldprint("======================================")
oldprint(str)
oldprint("======================================")
end
end
print("Hello World")
os.exit(0)
I understand everything except the magical working of argument str. How does
the oldprint(str) between the lines of equal know that the str arg in the
function declaration refers to the argument of the original print()? Looks
like magic to me, and I'm going to have to explain it.
Thanks
SteveT
--
Steve Litt
Recession Relief Package
http://www.recession-relief.US
Twitter: http://www.twitter.com/stevelitt