In Perl 6, you don't have to declare a type of a variable, but you can do so if you want to. The same rules apply to the arguments of a sub and to its return value.
Type constraints
Typed parameters
In the previous sections of this chapter, we did not say anything about the types of the $a and $b parameters of the add function. The code of the sub assumes that the arguments should be numeric because the + operator is used. Calling a function with two strings as arguments, for example, add('Hello', 'World'), will generate the following runtime error:
Cannot convert string to number: base-10 number must begin with valid digits or '.' in 'Hello' (indicated by )
This exception happens...