[chuck-users] Mixed Object Lists and Hierarchy

mike clemow gelfmuse at gmail.com
Fri Dec 11 14:28:28 EST 2009


Hi list,

Why can't I make an array of a parent type with objects of a single
type, which is a child of the parent?

class Foo
{
    int foo;
}

class Bar extends Foo
{
    int bar;
}

class Spam extends Foo
{
    int spam;
}

Bar bara, barb, barc;
Spam spama, spamb, spamc;
Foo fooa, foob, fooc;

[ bara, barb, barc ] @=> Bar bars[];   // okay
[ bara, spamb, fooc ] @=> Foo foos[];  // mixed children okay
[ bara, barb, barc ] @=> Foo morefoos[];  // incompatible types for assignment?


best,
Mike


-- 
http://michaelclemow.com
http://semiotech.org


More information about the chuck-users mailing list