I think one of Lua's nice features is that all functions are first-
class functions. That makes it possible to override behavior like
this:
-- Sample stolen from Wikipedia
local oldprint = print -- Store current print function as
oldprint
print = function(s) -- Redefine print function
if s == "foo" then
oldprint("bar")
else
oldprint(s)
end
end
I think one of Lua's nice features is that all functions are first-
class functions. That makes it possible to override behavior like
this:
-- Sample stolen from Wikipedia
local oldprint = print -- Store current print function as
oldprint
print = function(s) -- Redefine print function
if s == "foo" then
oldprint("bar")
else
oldprint(s)
end
end