aboutsummaryrefslogtreecommitdiff
path: root/api/paths.md
diff options
context:
space:
mode:
Diffstat (limited to 'api/paths.md')
-rw-r--r--api/paths.md28
1 files changed, 24 insertions, 4 deletions
diff --git a/api/paths.md b/api/paths.md
index c69e91d9..07f0560b 100644
--- a/api/paths.md
+++ b/api/paths.md
@@ -108,14 +108,14 @@ path | `Path` | The path of the file. | -
```tomo
# Safely handle file not being readable:
if lines := (./file.txt).by_line()
-for line in lines
-say(line.upper())
+ for line in lines
+ say(line.upper())
else
-say("Couldn't read file!")
+ say("Couldn't read file!")
# Assume the file is readable and error if that's not the case:
for line in (/dev/stdin).by_line()!
-say(line.upper())
+ say(line.upper())
```
## Path.can_execute
@@ -562,6 +562,26 @@ path | `Path` | The path to check. | -
assert (./link).is_symlink() == yes
```
+## Path.lines
+
+```tomo
+Path.lines : func(path: Path -> [Text]?)
+```
+
+Returns a list with the lines of text in a file or returns none if the file could not be opened.
+
+Argument | Type | Description | Default
+---------|------|-------------|---------
+path | `Path` | The path of the file. | -
+
+**Return:** A list of the lines in a file or none if the file couldn't be read.
+
+
+**Example:**
+```tomo
+lines := (./file.txt).lines()!
+
+```
## Path.modified
```tomo