whats wrong with this?
julia> filter(((k,v))->k=="a", testdict)
I know that
julia> filter((kv)->kv[1]=="a", testdict)
works
You're missing a comma.
((k,v))->k=="a"
is the same as
(k,v)->k=="a",
You instead need to write
filter(((k,v),)->k=="a", testdict)
This is kinda an unfortunate thing with anonymous functions in julia
This is one area where do
blocks are nice, because you need just one layer of parens:
filter(testdict) do (k, v)
k == "a"
end
ahhh I see! Thanks for clarifying. I actually like the do
block more, the comma is a bit weird
Last updated: Nov 22 2024 at 04:41 UTC