[Pharo-dev] Spec new release :)

Esteban Lorenzano estebanlm at gmail.com
Tue Nov 12 07:41:09 EST 2013


biut that method can be written: 

aMenu addGroup: (MenuGroupModel new 
	addItem: (MenuItemModel new 
		name: 'Browse Full';
		action: [ self browseSelectedObject ];
		shortcut: $b command mac | $b alt win | $b alt unix);
	addItem: (MenuItem new 
		name: 'Browse Class';
		action: [ self browseSelectedObjectClass ])).

and you do not have to declare variables for that (and is a lot better than using a block, IMO). 



On Nov 12, 2013, at 9:36 AM, Benjamin <Benjamin.VanRyseghem.Pharo at gmail.com> wrote:

> One can just use an object too.
> 
> It’s just that otherwise, it pollutes a bit the method with tons of inst vars
> (and then you forget to use them :P)
> 
> Ben
> 
> On 12 Nov 2013, at 13:05, Esteban Lorenzano <estebanlm at gmail.com> wrote:
> 
>> 
>> On Nov 12, 2013, at 4:22 AM, Benjamin <benjamin.vanryseghem.pharo at gmail.com> wrote:
>> 
>>> It is not necessary better, but it saves you from having hundreds of temp vars :)
>>> 
>>> Ben
>>> 
>>> On 12 Nov 2013, at 01:49, Stéphane Ducasse <stephane.ducasse at inria.fr> wrote:
>>> 
>>>>> 
>>>>> Example:
>>>>> aMenu addGroup: [ :aGroup |
>>>>> 	aGroup addItem: [ :anItem |
>>>>> 		anItem name: 'Browse Full';
>>>>> 		action: [ self browseSelectedObject ];
>>>>> 		shortcut: $b command mac | $b alt win | $b alt unix  ].
>>>>> 	aGroup addItem: [ :anItem |
>>>>> 		anItem name: 'Browse Class';
>>>>> 		action: [ self browseSelectedObjectClass ] ] ].
>>>>> 	
>>>> 
>>>> I do not see the value of passing block to add element to groups 
>>>> why not the normal way i.e. passing an object. I do not get why executing
>>>> a block with an object is better?
>> 
>> he, I thought the same :)
>> 
>>>> 
>>>> Stef
>>>> 
>>> 
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131112/beedf308/attachment-0002.html>


More information about the Pharo-dev mailing list