-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added eltype(itr::EachLine) #6114
Conversation
Also reimplemented one argument readlines() with collect.
@@ -226,6 +226,11 @@ function done(itr::EachLine, nada) | |||
true | |||
end | |||
next(itr::EachLine, nada) = (readline(itr.stream), nothing) | |||
eltype(itr::EachLine) = String |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't readline
always return a ByteString
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think so, as ByteString == Union(UTF8String,ASCIIString)
. Is there a lot of benefit using a Union instead of an abstract as type of an array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I doubt it matters much in practice, but my instinct was to declare the narrowest correct type on general principles.
I forgot about the trailing function arguments to |
Another potential application of
|
Wouldn't |
It would just be a hook to generate a special type of expression. If the argument is not to be evaluated, you pretty much need something like that. |
Similar to the julia side of the definition of the |
The type returned from
readlines
isArray{Any,1}
, and theEachLine
iterator does not specify an element type. This PR attempts to fix those two issues.There is still an issue with the way list comprehensions are used in
collect
that makes the inferred type fromreadlines
wider than necessary (Union(Array{String,1},Array{Union(UTF8String,ASCIIString),N})
).Not sure if that is an issue that should be reported elsewhere.