On Sun, 17 Jan 2010, Tudor Girba wrote:

> Hi,
>
> I have a method that takes OBCommands and returns Actions:
>
> actionsFrom: aCollectionOfOBCommandClasses on: aTarget for: aRequestor
>       | command |
>       ^ aCollectionOfOBCommandClasses collect: [ :each |
>               command := each on: aTarget for: aRequestor.
>               GLMAction new
>                       icon: command icon;
>                       title: command label;
>                       action: [:presentation | command execute ];
>                       yourself
>               ]
>
> These actions have a block that will be executed at a later time. The
> problem here was that the command in the action block was always
> pointing to the same command object, even at each point the command
> variable was populated correctly.
>
> However, when the command is defined inside the block, everything
> works as expected.
>
> actionsFrom: aCollectionOfOBCommandClasses on: aTarget for: aRequestor
>       ^ aCollectionOfOBCommandClasses collect: [ :each |
>               | command |
>               command := each on: aTarget for: aRequestor.
>               GLMAction new
>                       icon: command icon;
>                       title: command label;
>                       action: [:presentation | command execute ];
>                       yourself
>               ]
>
> I believe this is a bug.

This is exactly how it should work, it's a feature that I used to use.


Levente

>
> Cheers,
> Doru
>
> --
> www.tudorgirba.com
>
> "Obvious things are difficult to teach."
>
>
>
>
> _______________________________________________
> Pharo-project mailing list
> [email protected]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to