[squeak-dev] #ensure: What would you expect?

Bert Freudenberg bert at freudenbergs.de
Fri Dec 2 14:32:47 UTC 2011


On 02.12.2011, at 15:18, Tobias Pape wrote:

> Dear All,
> 
> given the following class:
> 
> Object subclass: #Foo
>        instanceVariableNames: ''
>        classVariableNames: ''
>        poolDictionaries: ''
>        category: 'Foo'!
> a
>        self b: [^ 1].! !
> 
> b: aBlock
> 
>        [self c: aBlock] ensure: [^ 2].
> 
> c: aBlock
> 
>        aBlock value.
>        ^ 3
> 
> And you would do
> 
> Foo new a
> 
> what would you expect?
> 
> I am very curious.
> Please, first guess, then execute.
> 
> Best
> 	-Tobias
> 
> 
> <Foo.st>


I expected two possible outcomes (because putting a return in the ensure block is unusual).

But what it actually answers is surprising.

- Bert -




More information about the Squeak-dev mailing list