Thanks a lot!
On Tuesday, February 23, 2016 at 1:06:32 PM UTC+1, Mauro wrote:
>
> You also need to splat when calling boo. Adding and `@show` helps to see
> what's going on:
>
>
> julia> function foo(a, b, x...)
> @show x
> boo(x...)
> end
> foo (generic function with 1 method)
>
> julia> foo(1,2,z...)
> x = (3,4)
> 12
>
> Below does not work as x is a tuple of one tuple, which becomes a single
> tuple after splatting in the boo call.
>
> julia> foo(1,2,z)
> x = ((3,4),)
> ERROR: MethodError: `boo` has no method matching boo(::Tuple{Int64,Int64})
> Closest candidates are:
> boo(::Any, ::Any)
> in foo at none:3
>
>
> On Tue, 2016-02-23 at 12:59, Alex <[email protected] <javascript:>>
> wrote:
> > Hi all,
> >
> > Why the following code doesn't work?
> >
> > function boo(x, y)
> > x*y
> > end
> >
> >
> > function foo(a, b, x...)
> > boo(x)
> > end
> >
> > z=3,4
> >
> > foo(1,2,z)
> > foo(1,2,z...)
> >
> > ERROR: LoadError: MethodError: `boo` has no method matching
> boo(::Tuple{Tuple{
> > Int64,Int64}})
> >
> > According to the documentation:
> >
> >
> > it is often handy to “splice” the values contained in an iterable
> > collection into a function call as individual arguments.
> >
> > To do this, one also uses ... but in the function call instead
> >
> >
> > I used ... in a function call, but it doesn't help.
>