Skip to content

Commit ad95dd5

Browse files
committed
Fix doc examples for writer with do-syntax
1 parent 149d3a7 commit ad95dd5

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docs/src/files.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,20 @@ UInt8[]
9898
To use it correctly, either call `flush`, or close the writer first (which also closes the underlying stream).
9999
It is recommended to use readers and writers to `do` syntax in the form:
100100
```julia
101-
Writer(open(my_file)) do writer
101+
FASTAWriter(open(my_path, "w")) do writer
102102
for record in my_records
103103
write(writer, record)
104104
end
105105
end
106106
```
107107

108-
Which will work for most underlying IO types.
108+
Which will work for most underlying IO types, and will close the writer when the function returns (hence also closing the underlying IO).
109+
110+
Alternatively, the following syntax may be used:
111+
```julia
112+
open(FASTAWriter, my_path) do writer
113+
for record in my_records
114+
write(writer, record)
115+
end
116+
end
117+
```

0 commit comments

Comments
 (0)