code / tomo-koans

Lines447 Tomo432 INI9 Markdown6
(29 lines)
1 # Paths
3 func main()
5 # Tomo includes a built-in literal type for file paths
6 # A path is inside parentheses and begins with `/`, `~`, `.` or `..`
8 path := (/tmp/test-file.txt)
9 assert path == (/tmp/test-file.txt)
11 path.write("first")!
12 assert path.read() == "???"
14 path.append(",second")!
16 assert path.exists() == yes
18 assert path.parent()! == (/???)
20 assert path.extension() == "???"
22 assert path.parent()!.child("other-file.txt") == (/???)
24 assert (/tmp/test-*.txt).glob() == [???]
26 path.remove()!
28 assert path.exists() == ???