Course of Raku / Objects, I/O, and exceptions / Input and output / Working with files / Exercises

Save and read

Problem

Save a number to a file and load it back. Write the number 42 (followed by a newline) to a file called number.txt. Then read the file back, turn its content into an integer, and print that integer multiplied by two.

Example

The program prints:

84

Solution

See the solution

Course navigation

Quiz — spurt and slurp   |   Solution: Save and read