x=0 or: [10/x=y]
| a strm | strm := WriteStream with: (String new: 100). a := Array new: 10. a at: 1 put: 'fee fi fo fum'. a at: 2 put: 3.14159. a at: 3 put: 8. "THE FOLLOWING LINE IS THE ONLY NEW PART" 1 to: a size by: 2 do: [:i | (a at: i) printOn: strm]. strm contents
Add this method to BlockContext:
repeatUntil: doneTest self value. doneTest whileFalse: self.Or if you wanted to define it primitively, without using while, the following will work. (It is less efficient, but maybe more interesting.)
repeatUntil: doneTest self value. doneTest value ifFalse: [self repeatUntil: doneTest]
Object subclass: #Octopus instanceVariableNames: 'myblock' classVariableNames: '' poolDictionaries: '' setValue: x myblock := [x]. setBlock: y myblock := y. getValue ^ myblock valueWhat is the result of evaluating the following code? (The value in each case will be the value of the last o getValue expression.)
| o a | a := 3. o := Octopus new. o setValue: a. a := a+1. o getValueAnswer: 3
And what about this code?
| o a b | a := 3. b := [a]. o := Octopus new. o setBlock: b. a := a+1. o getValueAnswer: 4