Difference between revisions of "Object:typeOf"

(Created page with '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 …')
 
(Undo revision 12107 by Gim (talk))
 
(3 intermediate revisions by 3 users not shown)
Line 2: Line 2:
  
 
== Function ==
 
== Function ==
 
 
=== Synopsis ===
 
=== Synopsis ===
 
<source lang="lua">
 
<source lang="lua">
Line 11: Line 10:
 
=== Returns ===
 
=== Returns ===
 
{{param|boolean|b|True if the object is of the specified type, false otherwise.}}
 
{{param|boolean|b|True if the object is of the specified type, false otherwise.}}
 
 
== Examples ==
 
== Examples ==
 
 
=== Checking the type of an object ===
 
=== Checking the type of an object ===
 
<source lang="lua">
 
<source lang="lua">
Line 22: Line 19:
 
print(image:typeOf("MouseJoint")) -- outputs: false
 
print(image:typeOf("MouseJoint")) -- outputs: false
 
</source>
 
</source>
 
 
== See Also ==
 
== See Also ==
 
* [[parent::Object]]
 
* [[parent::Object]]
 
 
{{#set:Description=Checks whether an object is of a certain type.}}
 
{{#set:Description=Checks whether an object is of a certain type.}}
 +
{{#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.

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