This project is read-only.
1

Closed

Generic type conversion from Fixnum to Integer

description

(from Charles Lowe)
 
Generics don't seem to function properly with inheritance. Ie, this works:
 
System::Collections::Generic::List[Fixnum].new << 1
=> [1]
 
But, as I understand it, this should work and doesn't:
 
System::Collections::Generic::List[Integer].new << 1
mscorlib:0:in `ThrowWrongValueTypeArgumentException': The value "1" is not of type
"Ruby.Builtins.Integer" and cannot be used in this generic collection.
Closed May 12, 2009 at 6:42 PM by TomasMatousek
Integer is not a proper CLR supertype of Fixnum (Int32). Therefore this can't work. You need to use Object as generic type argument.

comments