The following seems to work, but I'm not sure whether it was what you
wanted:
import Base.getindex
type Foo{T <: Tuple}
end
getindex{T}(f::Foo{Tuple{T}}, index::T...) = 42
Foo{Tuple{Int}}()[9]
Bill.
On Wednesday, 23 March 2016 14:38:20 UTC+1, Tamas Papp wrote:
>
> Hi,
>
> My understanding was that ... in a method argument forms a tuple, but I
> don't know how to dispatch on that. Self-contained example:
>
> import Base.getindex
>
> type Foo{T <: Tuple}
> end
>
> getindex{T}(f::Foo{T}, index::T...) = 42
>
> Foo{Tuple{Int}}()[9] ## won't match
>
> ## workaround with wrapper:
>
> _mygetindex{T}(f::Foo{T}, index::T) = 42
> mygetindex{T}(f::Foo{T}, index...) = _mygetindex(f, index)
>
> mygetindex(Foo{Tuple{Int}}(), 9)
>
> Is it possible to make it work without a wrapper in current Julia?
>
> Best,
>
> Tamas
>