Types
- sp.cast(x, T) → T
For a given value
x
and a typeT
, castx
into typeT
. This can be used to fix the type of an expression. Often this is done for parameters of entrypoints and in order to resolve type ambiguities:smartpy@sp.entrypoint def ep(x, y): sp.cast(x, sp.int) ...
Note that this expression can be used both as a statement and as an expression, e.g. one can also write:
smartpyr = sp.cast(x, sp.int) + 1