Type Converters
Pre-release
Pre-release
This draft adds the potential to convert between types, using pre-registered converters (e.g. text -> number.)
The syntax is %Object% [parsed] as a[n] %Type%
. Example: "10" as an integer
or 10.5 as a number
.
When converting, a direct match is attempted first, after which the first valid conversion will be chosen. This means that when converting a number to a string, ByteSkript will first look for a number -> string converter, after which it will fall back to any that allows the input (finding object -> string.)
Any syntax library may register converters.