Difference between revisions of "Type"

From GiderosMobile
Line 20: Line 20:
  
 
In '''Gideros 2024.11'''+ there is this new type:
 
In '''Gideros 2024.11'''+ there is this new type:
 +
*'''"vector"''' (built with the ''vector'' function)
 
*'''"color"''' (built with the ''ColorValue'' function)
 
*'''"color"''' (built with the ''ColorValue'' function)
 
<syntaxhighlight lang="lua">
 
<syntaxhighlight lang="lua">
Line 43: Line 44:
 
=== See also ===
 
=== See also ===
 
'''[[Object]]'''</br>
 
'''[[Object]]'''</br>
 +
'''[[vector]]'''</br>
 
'''[[ColorValue]]'''
 
'''[[ColorValue]]'''
  
 
{{(global)}}
 
{{(global)}}

Revision as of 02:34, 8 November 2024

Available since: Gideros 2011.6
Class: (global)

Description

Returns the type of its only argument, coded as a string.

(string) = type(v)

The possible results of this function are:

  • "nil" (a string, not the value nil)
  • "number"
  • "string"
  • "boolean"
  • "table"
  • "function"
  • "thread"
  • "userdata"

In Gideros 2024.11+ there is this new type:

  • "vector" (built with the vector function)
  • "color" (built with the ColorValue function)
print(type(ColorValue(1, 0, 1, 1))) -- color
print(type(ColorValue)) -- function

Parameters

v: (any) value to get type from

Return values

Returns (string) type of the variable

Example

Checks if variable x is of type table

local x = {}
if type(x) == "table" then print("type is table")
else print("type is not table")
end

See also

Object
vector
ColorValue