You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What happens if GetInputValue() returns an integer and the port has a type T that is a float?
What value is returned by this method?
Answer:
The returned value is 0 (and always and only 0) because integer is not float and thus the check is False and the default value is returned. However, one would expect that an integer can be cast to a float, returning (T)obj instead.
The correct line on 157 should be return obj != null && obj.GetType().IsInstanceOfType(typeof(T)) ? (T)obj : default(T);
I get this part wrong all the time. I meantIsAssignableFrom but that doesn't actually work here either. Had to do this:
xNode/Scripts/NodePort.cs
Lines 155 to 158 in 82f7887
What happens if
GetInputValue()
returns an integer and the port has a typeT
that is a float?What value is returned by this method?
Answer:
The returned value is
0
(and always and only0
) becauseinteger is not float
and thus the check is False and the default value is returned. However, one would expect that an integer can be cast to a float, returning(T)obj
instead.The correct line on 157 should bereturn obj != null && obj.GetType().IsInstanceOfType(typeof(T)) ? (T)obj : default(T);
I get this part wrong all the time. I meant
IsAssignableFrom
but that doesn't actually work here either. Had to do this:The text was updated successfully, but these errors were encountered: