# Strange results with slurping

**URL:** <https://discourse.julialang.org/t/strange-results-with-slurping/93273>\
**Category:** General Usage\
**Created:** [January 20, 2023, 5:55pm UTC](https://discourse.julialang.org/t/strange-results-with-slurping/93273 "2023-01-20T17:55:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [January 20, 2023, 5:55pm UTC](https://discourse.julialang.org/t/strange-results-with-slurping/93273/1 "2023-01-20T17:55:14Z")

</div>

Here is a simple example that demonstrates that the `...` list expansion operator can exhibit strange behavior. Consider:

```julia
function tst(args...)
    @show args
end

arg1 = (a=3, b=4)
arg2 = (c=5, d=7)
arg3 = (c=5, f=7)

tst(arg1...);
tst(arg1..., arg2...); # <<< CASE 2
tst(arg1..., arg2..., arg3...);

```

which prints the result:

```julia
args = (3, 4)

3457

args = (3, 4, 5, 7, 5, 7)

```

The question is: why does the second example produce an output format different than the other two?  
Thanks for any insight.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [January 20, 2023, 6:02pm UTC](https://discourse.julialang.org/t/strange-results-with-slurping/93273/2 "2023-01-20T18:02:17Z")

</div>

what version of Julia are you on?

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

---

<div class="post-metadata">

**Author:** ![erlebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/erlebach/32/12973_2.png) [@erlebach](https://discourse.julialang.org/u/erlebach)\
**Post date:** [January 20, 2023, 6:09pm UTC](https://discourse.julialang.org/t/strange-results-with-slurping/93273/3 "2023-01-20T18:09:48Z")

</div>

Version 1.8.3  
Hard to imagine this kind of error occurring, even on less mature versions of Julia.

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [January 20, 2023, 6:20pm UTC](https://discourse.julialang.org/t/strange-results-with-slurping/93273/4 "2023-01-20T18:20:51Z")

</div>

> [@erlebach](#):
>
> The question is: why does the second example produce an output format different than the other two?  
> Thanks for any insight.

I don’t think it does. I get exactly what you’d expect in Julia 1.8:

```julia
julia> tst(arg1...);
args = (3, 4)

julia> tst(arg1..., arg2...); # <<< CASE 2
args = (3, 4, 5, 7)

julia> tst(arg1..., arg2..., arg3...);
args = (3, 4, 5, 7, 5, 7)

```

My guess is that you have some other method `tst` in your current session which happens to be more specific and applicable for the 4-argument case.

---

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [January 20, 2023, 9:59pm UTC](https://discourse.julialang.org/t/strange-results-with-slurping/93273/5 "2023-01-20T21:59:51Z")

</div>

> [@rdeits](#):
>
> My guess is that you have some other method `tst` in your current session which happens to be more specific and applicable for the 4-argument case

Is there any good way to remove a method from the methodtable? I usually restart my session, but that can be inconvenient sometimes.

---

<div class="post-metadata">

**Author:** ![jar1](https://avatars.discourse-cdn.com/v4/letter/j/c0e974/32.png) [@jar1](https://discourse.julialang.org/u/jar1)\
**Post date:** [January 20, 2023, 10:17pm UTC](https://discourse.julialang.org/t/strange-results-with-slurping/93273/6 "2023-01-20T22:17:12Z")

</div>

`Base.delete_method`

---

<div class="post-metadata">

**Author:** ![uniment](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/uniment/32/24532_2.png) [@uniment](https://discourse.julialang.org/u/uniment)\
**Post date:** [January 20, 2023, 10:34pm UTC](https://discourse.julialang.org/t/strange-results-with-slurping/93273/7 "2023-01-20T22:34:47Z")

</div>

Could be nice?

```julia
julia> tst(arg1...);
args = (3, 4)

julia> macro delete_which(ex)
           print("Warning: removing methods may cause unexpected behavior!\n\nDo you wish to proceed? [y/n]: ")
           yn=readline(stdin)
           if yn ≠ "y"; println("Method deletion cancelled")
           else println("Deleting @which ", ex); esc(:( Base.delete_method(@which $ex) )) end
       end
@delete_which (macro with 1 method)

julia> @delete_which tst(arg1...)
Warning: removing methods may cause unexpected behavior!

Do you wish to proceed? [y/n]: y
Deleting @which tst(arg1...)

julia> tst(arg1...);
ERROR: MethodError: no method matching tst(::Int64, ::Int64)

```
