Skip to content

Commit 0013a6d

Browse files
committed
examples: Add a new example for working with files
1 parent 00c5bfc commit 0013a6d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

examples/files.pics

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
IO :: import std.io
3+
Fs :: import std.fs
4+
Error :: import std.errors
5+
6+
getContents :: ({fileName: path}) =
7+
let
8+
file := Fs::readToString(path)
9+
result := file catch return Error::error("Failed to read file: {err}")
10+
in Error::success(result)
11+
12+
result := getContents({fileName: "main.pics"}) catch err
13+
IO::println(result)
14+
15+

0 commit comments

Comments
 (0)