Login  Register

How can I make this more OOP

Posted by Pharo Smalltalk Users mailing list on Sep 13, 2020; 9:26am
URL: https://forum.world.st/How-can-I-make-this-more-OOP-tp5121729.html

Hello,

I know that OOP is not asking a object what it is but I have to flatten a array so I did this :

flattenArray: aCollection
    ^ (OrderedCollection
        streamContents: [ :stream | self flatten: aCollection into: stream ])
        asArray

flatten: anObject into: result
    ^ anObject isCollection
        ifTrue: [ anObject do: [ :item | self flatten: item into: result ] ]
        ifFalse: [ anObject ifNotNil: [ result nextPut: anObject ] ]

The name flattenArray is given bij exercism. 

Now I wonder how I can make this more a OOP solution. 

Can someone give me some hints or some examples ?

Roelof