Course of Raku / Essentials / Typed variables / Exercises

Create variables of all known types

Task

Write a program that creates a few scalar variables and initialises them with the values of the following types: Int, Rat, Num, Bool, and Str. The program should print both the value and its type.

Example

The actual output of the program may differ, but the idea is illustrated with the following test run:

$ raku types.raku
151 (Int)
4.2 (Rat)
1e10 (Num)
True (Bool)
xyz (Str)

Solution

See the solution

Course navigation

Data type conversion / Converting types with prefix operators   |   Positional data types