Double-colon operator

The double-colon operator or type operator is a binary operator where the left-hand side is an expression or expression sequence, and the right side is a type or an expression sequence of types.

We will use :: when we define procedures, but we can already use it in functions:

[> f := (n::integer) -> nextprime( nextprime( n ) ):
[> f( 18 ):

$23$

[> f( 18.5 ):
Error, invalid input: f expects its 1st argument, n, to be of type integer, but received 18.5

Later, when you are getting into using Maple as a programming language, you can assert that a variable is being assigned an appropriate type:

[> counter::integer := 3.1415;

$counter := 3.1415$

The kernelopts(...) directs the Maple engine or kernel to set specific options, and the assertlevel option, if set to 2, will verify such assignments:

[> kernelopts( 'assertlevel' = 2 ):
[> counter::integer := 3.1415;
Error, assertion failed in assignment to counter, expected integer, got 3.1415
[> counter::integer := 3;

$counter := 3$