suve

awful: function: typeof

Declaration

string :typeof ( mixed $VALUE )

Summary

Returns a string describing the type of VALUE. This can be used to check if a value needs typecasting, to distinguish between values which are loosely equal, or as an alternative way to check a function's return type.

  • When passed a NIL, returns nil.
  • When passed a logical (boolean) value, returns bool.
  • When passed a number, returns bin, oct, int, or hex.
  • When passed a float, returns float.
  • When passed a string, returns string.
  • When passed an array, returns array.
  • When passed a dictionary, returns dict.
  • If unable to determine type, returns ???.

Example

# typeof example.
!fun :randomtype
    !if :random i2
        :return i0
    !else
        :return s'0'
    !fi
!nuf

:writeln :typeof :randomtype

wikipage modified on 2014/0601/2317