Course of Raku / Objects, I/O, and exceptions / Input and output / Deleting files and directories / Exercises / Delete a file
Solution: Delete a file
Here is a possible solution to the task.
Code
spurt 'note.txt', 'temporary';
say 'note.txt'.IO.e;
unlink 'note.txt';
say 'note.txt'.IO.e;🦋 You can find the source code in the file delete-a-file.raku.
Output
True
FalseComments
spurtcreates the file, so the first.etest reportsTrue.unlinkdeletes it. The second.etest then reportsFalse, because the file is gone. Note the use of.erather than.f: the type test.fwould throw on a path that no longer exists, while.esimply answersFalse.