Conversion between basic types

Basic types can be have your values converted into another basic type through special keywords such as:

func asByte -> Byte
func asShort -> Short
func asLong -> Long
func asFloat -> Float
func asDouble -> Double
func asChar -> Char
func asBoolean -> Boolean
func asInt -> Int
func asString -> String

And then we have the possibility to perform a conversion between any of the basic types.

var Double d = 1.0;
var Int n = d asInt;
var String s = n asString;

The methods of the String prototype return an union of the type with Nil, as in

func asInt -> Int|Nil

Hence, they should be used with the cast or type-case statements:

cast n = "100" asInt {
(n*n - 2*n) println

A line read as a string can be converted into an Int as shown in the next example.

cast n = (In readLine) asInt {
(n*n - 2*n) println