I need some help in understanding the behavior of the following code.  It creates two subclasses, one of List and one of Stem, that inherit from a mixin class which adds a single method named Count.  I would expect that method  to behave the same for instances of either subclass but it does not.  Here is the code:

-- test the added Count method

    aColl = .listX~new
    aColl~append('One')
    aColl~append('Two')
    say aColl~items 'items'
    aColl~count     -- says '2'

    sColl. = .stemX~new
    sColl.foo = 'One'
    sColl.bar = 'Two'
    say sColl.~items 'items'
    sColl.~count    -- says '0' !

-- a class to add a Count method to another class
::class addCount mixinclass Object public

::method count
    say self~items

::class listX subclass list inherit addCount

::class stemX subclass stem inherit addCount

The output is:

2 items
2
2 items
0

--
Gil Barmwater



_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to