Hello,
I just came across the docstring of collect (Collections and Data Structures · The Julia Language) and I’ve got the feeling that the second usage example would need some more explanation, or is it just me?
julia> [x^2 for x in 1:8 if isodd(x)]
4-element Vector{Int64}:
  1
  9
 25
 49
(the first example is more simply collect(1:2:13))
The way I understand this example is that “if you put a Generator inside brackets, you get the same result as collect(…)'ing that generator”. Is my interpretation correct?
Also, if my interpreation is correct, I believe that mentioning the [...] notation/operator would require an additional warning, because the similarity is partial:
- indeed [i for i in 1:3]andcollect(i for i in 1:3)both returns the same 3-elementVector{Int64}
- however, [1:3]returns a 1-elementVector{UnitRange{Int64}}, whilecollect(1:3)returns the same 3-elementVector{Int64}as before