Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ If that function is defined, you can do things like that:
```clojure
(println*
&(using (Result.unsafe-from-success (File.open "example")) f
&(File.read-all &f)))
(the (Result String String) (File.read-all &f))))
```

The file that was opened will be automatically closed once the scope is exited.
Expand Down
6 changes: 3 additions & 3 deletions examples/file.carp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
(load "main.carp")
(load "git@github.com:carpentry-org/file.git@master")
(load "git@github.com:carpentry-org/file.git@0.3.0")

(implements close File.close)

(defn main []
(println*
&(using-do (Result.unsafe-from-success (File.open "example")) f
&(using-do (Result.unsafe-from-success (File.open-with "example" "w+")) f
(ignore (File.write &f "hi"))
(File.rewind &f)
(File.read &f 2))))
(the (Result String String) (File.read &f 2)))))