Is there a way to write a block ( which does not get any parameters) which does something only at the first call.
I want to initialize a local block variable only at the first time and then change its value each time the user call that block by : Block value.
My block will be defined in a method A inside a class B. and the method returns the block.
so each time I call method A it should do the initialization. but every time I call the block it should continue from the same point.
for example: I want i to be initialized to 0.
A
^[i:=i+1]
ob1 = B new.
res= obj1 A.
Transcript show: res value. // should print 1
Transcript show: res value. // should print 2
res2= obj1 A.
Transcript show: res2 value. // should print 1