Anonymous user
History variables: Difference between revisions
m
→{{header|Lua}}
m (→{{header|Lua}}) |
|||
Line 1,213:
<lang lua>-- History variables in Lua 6/12/2020 db
local HistoryVariable = {
history = {},
new = function(self)
Line 1,219 ⟶ 1,218:
end,
get = function(self)
return self.
end,
set = function(self, value)
self.history[#self.history+1] = value
end,
undo = function(self)
self.history[#self.history] = nil
end,
Line 1,239 ⟶ 1,236:
hv:set(2); print("set() to:", hv:get())
hv:set(3); print("set() to:", hv:get())
hv:set(nil); print("set() to:", hv:get())
--
print("history:", table.concat(hv.history,","))
|