typeof - returns the Type of value
typeof(val
)
The typeof()
intrinsic procedure returns the
scalar type of its argument. The scalar type is always
a Type
, never a class, and it is, as its name
suggests, a scalar with no dimensionality.
Value | scalar type | parent |
---|---|---|
class foo |
Class |
nil |
foo bar() |
Object |
foo |
[1,2,3] |
PackInt |
PackInt[3] |
PackInt[3] |
Type |
PackInt |
PackInt |
Type |
Array |
The scalar type of a given value
None
// Note the difference between typeof and x.parent a = [1,2,3] typeof(a) PackInt a.parent PackInt[3] class foo { public var x; } typeof(foo) Class foo.parent nil foo bar() typeof(bar) Object bar.parent foo a = PackInt[3] typeof(a) Type a.parent PackInt