Skip to content

Commit eb11a30

Browse files
committed
example: Fixed a syntax error and added 2 more examples
1 parent 090fa14 commit eb11a30

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

examples/modules2.pics

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
IO :: import std.io
3+
4+
Person :: module {
5+
new :: (name, age) = {name: name, age: age}
6+
}
7+
8+
9+
Animal :: module {
10+
new :: ("Woof") = {name: "Dog"}
11+
new :: (name) = {name: name}
12+
}
13+
14+
person := Person::new("Vincent", 23)
15+
IO::println(person)
16+
17+
test :: (value) = value
18+
19+
20+
cat := Animal::new("cat")
21+
cat
22+
|> test
23+
|> IO::println()
24+
25+
cat := Animal::new("Woof")
26+
cat
27+
|> test
28+
|> IO::println()
29+
30+

examples/ref.pics

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
IO :: import std.io
3+
Ref :: import std.ref
4+
5+
ref := &5
6+
IO::println(ref)
7+
Ref::set(ref, "Hello")
8+
IO::println(ref)

examples/when.pics

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ when a {
2424
when a {
2525
is [2,b,c,4] -> IO::println(b + " " + c)
2626
is [a,b, c,4] -> IO::println(a + " " + b + " " + c)
27-
else -> IO::println("No match")"
27+
else -> IO::println("No match")
2828
}

0 commit comments

Comments
 (0)