? type([0][0]) = type(box(0))
'======================== TYPE CHECKS =========================
' Apparently all of these are a lot faster than doing something like: IF Type(Th.spriteDraw) <> "roBoolean" ' or: IF Type(id) = "String" OR Type(id) = "roString"
' All these from The Endless: http://forums.roku.com/viewtopic.php?f=34&t=82858&view=unread#p476634
Function IsBoolean(value As Dynamic) As Boolean
Return GetInterface(value, "ifBoolean") <> INVALID
End Function
Function IsString(value As Dynamic) As Boolean
Return GetInterface(value, "ifString") <> INVALID
End Function
Function IsArray(value As Dynamic) As Boolean
Return GetInterface(value, "ifArray") <> INVALID
End Function
Function IsAssociativeArray(value As Dynamic) As Boolean
Return GetInterface(value, "ifAssociativeArray") <> INVALID
End Function
Function IsInteger(value As Dynamic) As Boolean
Return GetInterface(value, "ifInt") <> INVALID And (Type(value) = "roInt" Or Type(value) = "roInteger" Or Type(value) = "Integer")
End Function
Function IsFloat(value As Dynamic) As Boolean
Return (GetInterface(value, "ifFloat") <> INVALID Or (Type(value) = "roFloat" Or Type(value) = "Float"))
End Function
Function IsDouble(value As Dynamic) As Boolean
Return (GetInterface(value, "ifDouble") <> INVALID Or (Type(value) = "roDouble" Or Type(value) = "roIntrinsicDouble" Or Type(value) = "Double"))
End Function
Function IsList(value As Dynamic) As Boolean
Return GetInterface(value, "ifList") <> INVALID
End Function
Function IsDateTime(value As Dynamic) As Boolean
Return (GetInterface(value, "ifDateTime") <> INVALID Or Type(value) = "roDateTime")
End Function
Function IsXmlElement(value As Dynamic) As Boolean
Return GetInterface(value, "ifXMLElement") <> INVALID
End Function
Function IsFunction(value As Dynamic) As Boolean
Return GetInterface(value, "ifFunction") <> INVALID
End Function
Function IsHttpAgent(value As Dynamic) As Boolean
Return GetInterface(value, "ifHttpAgent") <> INVALID
End Function
"thanhpham" wrote:? type([0][0]) = type(box(0))
In fact, this will print out "false".
The zero wrapped in an array has the type "roInteger" while the boxed zero has the type "roInt".
I am on firmware 7.5.
Brightscript Debugger> for each i in [1, [1][0], box(1), 1.0]: ? i, type(i), type(i, 3), getInterface(i, "ifInt") <> invalid: next
1 roInteger Integer true
1 roInteger Integer true
1 roInt roInt true
1 roFloat Float false