# Question about arguments passed to the filter function

**URL:** <https://discourse.julialang.org/t/question-about-arguments-passed-to-the-filter-function/36364>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 22, 2020, 8:57pm UTC](https://discourse.julialang.org/t/question-about-arguments-passed-to-the-filter-function/36364 "2020-03-22T20:57:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![CH-8](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@CH-8](https://discourse.julialang.org/u/CH-8)\
**Post date:** [March 22, 2020, 8:57pm UTC](https://discourse.julialang.org/t/question-about-arguments-passed-to-the-filter-function/36364/1 "2020-03-22T20:57:06Z")

</div>

Hi,

The code block below achieves its purpose but Julia provides a warning for how the argument is passed.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/f/ffdbedc89a4d61baf9bd2adaf4f083f31b7b0bf5.png)

```julia

key1 = [1, 1, 2, 3, 3, 4]; key2 = [2, 3, 4, 4, 5, 5]
value = [0.3, 0.145, 0.032, 0.260, 0.320, 0.500]
Data = Dict{Tuple{Int64, Int64}, Float64}();
for i in 1:6
    Data[(key1[i],key2[i])] = value[i]    
end
filter(((k1,k2),v) -> k1 == 1, Data)

```

Is there a correct way to rewrite this so that the warning is not triggered?

Any help would be much appreciated.  
Also, apologies if my question is posted in the wrong section of the forum (or not following the guidelines).  
I am new to this…

---

<div class="post-metadata">

**Author:** ![Skoffer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/skoffer/32/378_2.png) [@Skoffer](https://discourse.julialang.org/u/Skoffer)\
**Post date:** [March 22, 2020, 10:15pm UTC](https://discourse.julialang.org/t/question-about-arguments-passed-to-the-filter-function/36364/2 "2020-03-22T22:15:20Z")

</div>

Problem is that `Dict` iterator returns `Pair` not tuple of key-value. So, `filter` function is trying to destructure the Pair and gives you warning about it. Correct way (you may consider this [example from the documentation](https://docs.julialang.org/en/v1/base/collections/#Base.filter)) is to take whole pair as a single argument and destructure it inside the function

```julia
filter(p -> p.first[1] == 1, Data)

```

---

<div class="post-metadata">

**Author:** ![CH-8](https://avatars.discourse-cdn.com/v4/letter/c/41988e/32.png) [@CH-8](https://discourse.julialang.org/u/CH-8)\
**Post date:** [March 22, 2020, 11:08pm UTC](https://discourse.julialang.org/t/question-about-arguments-passed-to-the-filter-function/36364/3 "2020-03-22T23:08:40Z")

</div>

Thank you for your help!
