Hi,

I'm writing a data structure with generics, and needs an internal array to
store data.
But the array should be initialized with null value at the beginning.

public class Seq[ET] {
    public var S:Array[ET](1){rail};
    public var sz:int;

    public def this(s:int) {
                sz = s;
            S = new Array[ET](sz, null); //<==== problem here
    }
}

Because ET has no "hasZero" attribute. I don't know how to create the array
with null as initial value.

new Array[ET](sz, null), will treat "null" as "(int)=>ET", and throw NPE.
null cannot be casted to ET type, either.

Anyone can give some suggestions?

Best Regards,
-----------------------------------------------------------------
Hai Chuan(Haichuan) Wang,     王海川
Research Staff Member, System Software, IBM Research - China
TEL:   86-21-60924401    FAX:   86-21-60923522
------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to