Deducing the type of a mapping value

Find and share HowTos to various installations / configurations!
3 posts • Page 1 of 1
ottemot
Posts:13
Joined: Wed Dec 02, 2015 2:30 pm

Deducing the type of a mapping value

Post by ottemot »

Since the mapping data type allows you to use values of different data types, are there any way to check what datatype an entry is?

Say you're iterating through the keys of a mapping where some values are integers and some are strings. It would be convenient to know what kind data type they are before using the values.

As an extension to this question, are there any way to figure out the data type of an anytype/mixed variable once it has been assigned a value?

buec
Posts:28
Joined: Tue Dec 07, 2010 3:09 pm

Re: Deducing the type of a mapping value

Post by buec »

You can check the variable type with getType() and getTypeName().

ottemot
Posts:13
Joined: Wed Dec 02, 2015 2:30 pm

Re: Deducing the type of a mapping value

Post by ottemot »

Excellent, thank you!

3 posts • Page 1 of 1