RosettaCodeData/Task/History-variables/Sidef/history-variables.sidef
2016-12-05 23:44:36 +01:00

28 lines
406 B
Text

class HistoryVar(v) {
has history = []
has variable = v
method ≔(value) {
history << variable
variable = value
}
method to_s {
"#{variable}"
}
method AUTOLOAD(_, name, *args) {
variable.(name)(args...)
}
}
var foo = HistoryVar(0)
foo ≔ 1
foo ≔ 2
foo ≔ foo+3
foo ≔ 42
say "History: #{foo.history}"
say "Current value: #{foo}"