The docs for write say that it will return the number of bytes written to a stream. That means write(STDOUT,IOBuffer("a")) should return 1, instead it returns nothing.
The definition for this method is here: https://github.com/JuliaLang/julia/blob/master/base/io.jl#L567-L571
Loops return nothing and that's the last thing in the body.
diff --git a/base/io.jl b/base/io.jl
index ae71210cb1..06400023d1 100644
--- a/base/io.jl
+++ b/base/io.jl
@@ -565,9 +565,11 @@ function write(io::IO, s::Symbol)
end
function write(to::IO, from::IO)
+ i = 0
while !eof(from)
- write(to, readavailable(from))
+ i += write(to, readavailable(from))
end
+ return i
end
?
Most helpful comment
?