-------- Doorgestuurd bericht --------
Onderwerp: Re: [Pharo-users] How can I make this more OOP
Datum: Sun, 13 Sep 2020 16:43:59 +0200
Van: Roelof Wobben <r.wob...@home.nl>
Aan: Noury Bouraqadi <bouraq...@gmail.com>


Hello, Noury,

Thanks for letting me see this but  I wonder if it is good practice to place my own methods on the Object and UndefinedObject ?

Roelof


Op 13-9-2020 om 14:51 schreef Noury Bouraqadi:
Hi Roelof,

Polymorphism is the answer.

Object >> flattenInto: result
result nextPut: anObject

UndefinedObject >> flattenInto: result
^self

Collection >> flattenInto: result
self do: [ :item | item flattenInto: result ]

flatten: anObject
    ^ (OrderedCollection streamContents: [ :stream | anObject flattenInto: stream ]) asArray

Noury



Reply via email to