On Thu, Jun 4, 2015 at 8:50 AM, Christoph Ortner
<[email protected]> wrote:
>
> When implementing a function (overloading getindex to be precise) to allow :
> as an argument I expected that I would need to do the following:
>
> funA(_::Colon) = println("funA")
>
> but the following works as well
>
> funB(:) = println("funB")

You are just defining a method with `:` being it's (weird) argument name.

`:` is a global constant but it doesn't have any special meaning for
the parser. You can override it with local variables just like any
other globals.

Here's how you can figure out the signature of that method.

```julia
julia> f(:) = 1
f (generic function with 1 method)

julia> methods(f, Tuple{Any})
1-element Array{Any,1}:
f(:) at none:1

julia> methods(f, Tuple{Any})[1].sig
Tuple{Any}
```

>
> Why? When I type ?: in the REPL I find that : is an instance of Colon. This
> is unexpected for me, it does not seem to be the same as "Value Types"? Can
> somebody clarify for me what is happening?
>
> Many thanks,
>    Christoph
>

Reply via email to