History variables: Difference between revisions

(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 550:
(h-undo x) → ❌ error: no more values x
</lang>
=={{header|Elena}}==
ELENA 3.2 :
<lang elena>import extensions.
import system'collections.
import system'routines.
import extensions'routines.
 
class HistoryVariable
{
object prop Value :: _value.
stack _previous := Stack new.
 
set Value:v
[
if ($nil != _value)
[
_previous push(_value)
].
_value := v
]
undo
[
ifnot (_previous isEmpty)
[
_value := _previous pop
];
[
_value := $nil
]
]
enumerator => _previous.
dispatch => _value.
}
 
program =
[
var o := HistoryVariable new.
o Value := 5.
o Value := "foo".
o Value := o Value + "bar".
console printLine(o).
o forEach:printingLn.
o undo; undo; undo.
console printLine(o Value).
].</lang>
{{out}}
<pre>
foobar
foo
5
 
</pre>
 
=={{header|Erlang}}==
Anonymous user