This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
YUGATUG's profile picture

find out type of variable?

Started by YUGATUG, 06 April 2015 - 07:34 PM
YUGATUG #1
Posted 06 April 2015 - 09:34 PM
Is there an api or function to get the type of variable a variable is?
MKlegoman357 #2
Posted 06 April 2015 - 09:40 PM
There's a function called 'type'. It returns the type of the variable as a string:


print( type( "" ) ) --> string

print( type( 1 ) ) --> number

You should really use google more often, it's way faster than asking here for these little things.
SquidDev #3
Posted 06 April 2015 - 09:41 PM
The type function is what you are looking for.

Edit: Ninja'd
Edited on 06 April 2015 - 07:41 PM
Dog #4
Posted 06 April 2015 - 09:41 PM
I believe type(variable) will return the type of variable.

EDIT: :ph34r:/> 'd
Edited on 06 April 2015 - 07:42 PM
YUGATUG #5
Posted 06 April 2015 - 10:15 PM
Uh… What is this ninja'd thing? Also thanks
MKlegoman357
Bomb Bloke #6
Posted 06 April 2015 - 10:20 PM
http://www.google.com/search?q=ninja'd