Jump to content

History variables: Difference between revisions

m
Line 551:
</lang>
=={{header|Elena}}==
ELENA 3.24 :
<lang elena>import extensions.
import system'collections.
import system'routines.
import extensions'routines.
 
class HistoryVariable
{
stack T<Stack> _previous := Stack new.
object prop Value :: _value.
stack _previous := Stack new.
 
set Value:v
[
if ($nil != _value)
[
_previous push(_value)
].
_value := v
]
undo
[
Line 579 ⟶ 580:
];
[
_value := $nilnilValue
]
]
enumerator => _previous.
dispatchT<literal> literal => _value.
}
 
programpublic =program
[
var o := HistoryVariable new.
Line 594 ⟶ 595:
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>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.