because your #tracks: returns self, not the collection value
> On 24 Jul 2019, at 16:46, sergio ruiz <sergio....@gmail.com> wrote:
>
> I'm implementing an instance variable as an OrderedCollection, and am doing
> something idiotic.
>
> I have an Artist class.
>
> An Artist can have many tracks:
>
> tracks
> ^ tracks ifNil: [ self tracks: OrderedCollection new ]
>
> tracks: anObject
> tracks := anObject
>
> Doing something like:
>
> a := Artist new.
> t := Track new.
> a tracks add: t
>
> Gives me the error:
>
> Artist(Object)>>doesNotUnderstand: #add:
>
> Once I get past that error, which will evaluate `a tracks`, I can run this.
>
> I get why it works the second time, but I don't get why it thinks the
> instance of Artist is the receiver of add: on the first run.
>
> Thanks!
> ----
> peace,
> sergio
> photographer, journalist, visionary
>
> Public Key: http://bit.ly/29z9fG0
> #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
> http://www.codeandmusic.com
> http://www.twitter.com/sergio_101
> http://www.facebook.com/sergio101
>