Skip to content
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

Anonymous functions don't work in generators #17979

Closed
timholy opened this issue Aug 11, 2016 · 2 comments
Closed

Anonymous functions don't work in generators #17979

timholy opened this issue Aug 11, 2016 · 2 comments

Comments

@timholy
Copy link
Member

timholy commented Aug 11, 2016

First noticed in #17968 (comment).

julia> d = Dict(:a=>"abc", :b=>"def")
Dict{Symbol,String} with 2 entries:
  :a => "abc"
  :b => "def"

julia> a = ["abc", "def"]
2-element Array{String,1}:
 "abc"
 "def"

julia> second(p) = p.second
second (generic function with 1 method)

julia> collect((second(p) for p in d))
2-element Array{String,1}:
 "abc"
 "def"

julia> collect((p->p.second for p in d))
2-element Array{##2#4,1}:
 #2
 #2

julia> collect((first(x) for x in a))
2-element Array{Char,1}:
 'a'
 'd'

julia> collect((x->x[1] for x in a))
2-element Array{##6#8,1}:
 #6
 #6

If this is the same as #15276, feel free to close.

@JeffBezanson
Copy link
Member

The expression evaluates to a function, so you get an array of functions. Looks to me like it is working.

@timholy
Copy link
Member Author

timholy commented Aug 11, 2016

Duh, right. 🐑

@timholy timholy closed this as completed Aug 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants