3

What is the best way to find out the type of a variable in Solidity? (something like typeof in JS)

2

Solidity is statically typed.

http://solidity.readthedocs.io/en/latest/types.html#types

Solidity is a statically typed language, which means that the type of each variable (state and local) needs to be specified (or at least known - see Type Deduction below) at compile-time. Solidity provides several elementary types which can be combined to form complex types.

  • What I mean is that, is it possible to have a function which could accept any type and depending on the type run the appropriate flow to convert that type to strings? I know it's possible to have same name functions with different number of input arguments, however is it possible to have same name functions which accept different types and they would be called according to the type of argument it's called with? – Shayan Jul 8 '16 at 18:45
  • "is it possible to have a function which could accept any type" No. For the last question, yes. See the link in the answer, which also mentions Type Deduction. – eth Jul 8 '16 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.