Difference between revisions of "Object:typeOf"
Line 1: | Line 1: | ||
− | + | Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true. | |
− | == | + | == Function == |
− | === | + | === Synopsis === |
<source lang="lua"> | <source lang="lua"> | ||
− | b = Object:typeOf( | + | b = Object:typeOf( name ) |
</source> | </source> | ||
− | === | + | === Arguments === |
− | {{param|string| | + | {{param|string|name|The name of the type to check for.}} |
− | === | + | === Returns === |
− | {{param|boolean|b| | + | {{param|boolean|b|True if the object is of the specified type, false otherwise.}} |
− | == | + | == Examples == |
− | + | === Checking the type of an object === | |
<source lang="lua"> | <source lang="lua"> | ||
image = love.graphics.newImage("test.png") | image = love.graphics.newImage("test.png") | ||
− | print(image:typeOf("Object")) | + | print(image:typeOf("Object")) -- outputs: true |
− | print(image:typeOf("Drawable")) | + | print(image:typeOf("Drawable")) -- outputs: true |
− | print(image:typeOf("Image")) | + | print(image:typeOf("Image")) -- outputs: true |
− | print(image:typeOf("MouseJoint")) -- | + | print(image:typeOf("MouseJoint")) -- outputs: false |
</source> | </source> | ||
− | + | == See Also == | |
− | == | + | * [[parent::Object]] |
− | * [[parent:: | + | {{#set:Description=Checks whether an object is of a certain type.}} |
− | |||
− | |||
− | |||
− | |||
− | {{#set:Description= | ||
{{#set:Since=000}} | {{#set:Since=000}} | ||
[[Category:Functions]] | [[Category:Functions]] | ||
+ | == Other Languages == | ||
+ | {{i18n|Object:typeOf}} |
Latest revision as of 19:07, 11 December 2013
Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true.
Contents
Function
Synopsis
b = Object:typeOf( name )
Arguments
string name
- The name of the type to check for.
Returns
boolean b
- True if the object is of the specified type, false otherwise.
Examples
Checking the type of an object
image = love.graphics.newImage("test.png")
print(image:typeOf("Object")) -- outputs: true
print(image:typeOf("Drawable")) -- outputs: true
print(image:typeOf("Image")) -- outputs: true
print(image:typeOf("MouseJoint")) -- outputs: false
See Also
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info