On Sat, Aug 29, 2015 at 11:17 AM, Diego Javier Zea <[email protected]> wrote:
> Hi!
>
> I'm confused with this...
>
> When do I need to use Symbol instead of ASCIIString on function arguments?
>
> Which of the following is the best and Julian definition?
Apart from their indented use (symbol in code/expression) symbols are
more or less like enums (or at least in your use case). I would
suggest using enums instead of either symbols or string.
>
>
> julia> myfunstr{T}(x::T; method::ASCIIString="one") = method=="one" ?
> one(T)+x : x
> myfunstr (generic function with 1 method)
>
>
> julia> myfunsym{T}(x::T; method::Symbol=:one) = method==:one ? one(T)+x : x
> myfunsym (generic function with 1 method)
>
>
> julia> myfunstr(10)
> 11
>
>
> julia> myfunsym(10)
> 11
>
>
> Thanks in advance,
> Best