[Pharo-users] Traits for class methods?

Vitor Medina Cruz vitormcruz at gmail.com
Mon Feb 11 14:02:52 EST 2019


Rectifying, It does as expected and self points to the target class. This
odd behavior happened to me when I implemented the initialize method on the
class side of a Trait and then clicked the 'Run Script' Button on the
target class.

On Mon, Feb 11, 2019 at 4:52 PM Vitor Medina Cruz <vitormcruz at gmail.com>
wrote:

> It seems, however, that self points to the trait class, instead of the
> target object class. Is that correct? Instance side methods behave as
> expected and self points to the target object.
>
> On Mon, Feb 11, 2019 at 2:19 PM Cyril Ferlicot <cyril.ferlicot at gmail.com>
> wrote:
>
>> On Mon, Feb 11, 2019 at 4:50 PM Konrad Hinsen
>> <konrad.hinsen at fastmail.net> wrote:
>> >
>> > Hi everyone,
>> >
>> > A quick question: is it possible to use traits to define class methods?
>> >
>> > For example, could the popular singleton pattern consisting of the
>> > three class methods #uniqueInstance, #new, and #reset plus the instance
>> > variable uniqueInstance be packaged as a trait?
>>
>> Hi,
>>
>> Yes it is possible.
>>
>> >
>> > Konrad.
>> >
>>
>>
>> --
>> Cyril Ferlicot
>> https://ferlicot.fr
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pharo.org/pipermail/pharo-users_lists.pharo.org/attachments/20190211/5c3b0a1c/attachment.html>


More information about the Pharo-users mailing list