Difference between revisions of "Object:typeOf (Español)"

(Comprobar el tipo de un objeto)
 
Line 14: Line 14:
 
<source lang="lua">
 
<source lang="lua">
 
image = love.graphics.newImage("test.png")
 
image = love.graphics.newImage("test.png")
print(image:typeOf("Object")) -- outputs: true
+
print(image:typeOf("Object")) -- salida: true
print(image:typeOf("Drawable")) -- outputs: true
+
print(image:typeOf("Drawable")) -- salida: true
print(image:typeOf("Image")) -- outputs: true
+
print(image:typeOf("Image")) -- salida: true
print(image:typeOf("MouseJoint")) -- outputs: false
+
print(image:typeOf("MouseJoint")) -- salida: false
 
</source>
 
</source>
 +
 
== Véase también ==
 
== Véase también ==
 
* [[parent::Object (Español)]]
 
* [[parent::Object (Español)]]

Latest revision as of 22:50, 18 May 2024

Comprueba si un objeto es de un tipo determinado. Si el objeto tiene el tipo con el nombre especificado en su jerarquía, esta función devolverá true.

Función

Sinopsis

b = Object:typeOf( name )

Argumentos

string name
El nombre del tipo de comprobar.

Devuelve

boolean b
True si el objeto es del tipo especificado, False en caso contrario.

Ejemplos

Comprobar el tipo de un objeto

image = love.graphics.newImage("test.png")
print(image:typeOf("Object")) -- salida: true
print(image:typeOf("Drawable")) -- salida: true
print(image:typeOf("Image")) -- salida: true
print(image:typeOf("MouseJoint")) -- salida: false

Véase también

Otros idiomas