Difference between revisions of "Object:typeOf"

m (added "Other Languages" section)
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 ==
 
== Other Languages ==
 
{{i18n|Object:typeOf}}
 
{{i18n|Object:typeOf}}

Revision as of 09:22, 25 March 2011

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