Skip to content

Commit a6e25c0

Browse files
committed
examples: Use string interpolation instead of the format function
1 parent 69ab9c1 commit a6e25c0

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

examples/errors.pics

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
IO :: import std.io
3+
Error :: import std.errors { Error { new, getValueOr } }
4+
5+
safeDiv :: (x, y) =
6+
when (x, y) {
7+
is (_, 0) -> Error::new("Divide by zero")
8+
else -> Error::success(x / y)
9+
}
10+
11+
result := Error::getValueOr(
12+
safeDiv(50, 0),
13+
|err| -> -1
14+
)
15+
16+
IO::println(result)
17+
18+

examples/virtual3.pics

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ getProfile :: (id = 0) = Virtual::task(|_| -> do {
1515
profile
1616
})
1717

18-
printProfile :: (kind, user) = IO::println(String::format("%s := {{name: %s}}", [kind, user.name]))
18+
printProfile :: (kind, user) = IO::println("{kind} := {user.name}")
1919

2020

2121
IO::println("Start")

0 commit comments

Comments
 (0)