sz1992
1
Hi,
if you try to iterate over ::Symbol you get an error:
MWE:
for i in :c @show i end
ERROR: MethodError: no method matching iterate(::Symbol)
however it works fine with Int:
for i in 5 @show i end
i = 5
note also that it works for:
for i in [:c] @show i end
Is there a solution for this?
1 Like
oheil
3
This is the solution, isn’t it?
Integers are iterable (I think for convenience, but have to search for the why), but not everything is iterable.
Another solution would be to implement iterate
for Symbol
.
Iterable Number
has been usefull before broadcasting was introduced in Julia 0.5. See discussions below.
oheil
4
1 Like
sz1992
5
Is there a rationale behind for not having Iterate
for Symbol
?
Yes, there is no point to it.
1 Like
oheil
7
As in the discussions above stated: there is not much rationale behind making Number
iterable.
1 Like