On Mon, Oct 12, 2015 at 2:07 PM, <[email protected]> wrote: > /*Function 1*/ > function fun1(::Int64) > > > /*Function 2*/ > function func2(::Type{Int64}) > > > Hi fellows, > > I am kind of confused what does these 2 parameter usages mean? > > Where are they used? What are the use cases?
See http://julia.readthedocs.org/en/latest/manual/types/#singleton-types ::Int64 means the argument can only be a Int64 and ::Type{Int64} means that the argument can only be of type Type{Int64} and therefore can only be the type Int64 (i.e. you call fun1 with fun1(Int64(1)) and fun2 with fun2(Int64)) You use these when you want to define a method/specialization of a function that's only applicable to these types. This is a really powerful tool that is hard to explain in a few sentense. It's probably the best to go through the document about methods[1] and probably try sth yourself or looking at some existing code in base or other packages. [1] http://julia.readthedocs.org/en/latest/manual/methods/ > > Thanks >
