29 lines
406 B
Plaintext
29 lines
406 B
Plaintext
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}"
|