Course of Raku / Advanced / Modules / Modules basics / Exercises / A shout module

Solution: A shout module

Here is a possible solution to the task. It uses two files.

Code

The module, Shouter.rakumod:

unit module Shouter;

sub shout($s) is export {
    $s.uc
}

The program, shout.raku:

use Shouter;

say shout('hi');

🦋 You can find both source files in the exercises/advanced/modules-basics/shout-module directory.

Output

$ raku -I. shout.raku
HI

Comments

  1. The is export trait makes shout visible to any program that uses the module.

  2. The .uc method returns the upper-case version of the string.

Course navigation

A shout module   |   Two functions in one module