Casting generic primitives vs objects
Monkey Forums/Monkey Programming/Casting generic primitives vs objects| 
 | ||
| Mark, you might be able to help me with this one. I want to be able to check if a generic implements an interface, but this means that it won't compile if the parameter is a primitive (which I want to allow). Class Foo<T>
  Method Test:Void(val:T)
    ' if primitive, do A
    If (val is primitive) Then
      ' do A
    ElseIf (val is object that implements an interface) Then
      ' do B
    End
  End
EndThere's no way of checking if T is a primitive, and obviously I can't cast to an interface if it is. Short of writing horrible native code, can you think of an easy solution? Thanks, Samah |