Hi Fil, The way to do that in Julia is simply to define another version of the function, which does the conversion and passes that on to the "main" version of the function:
test(str::String) = test(symbol(str)) Cheers, Kevin On Tue, Feb 11, 2014 at 3:30 PM, Fil Mackay <[email protected]>wrote: > Just wondering if there is an operator to easily perform known conversion. > Say I have a function that takes a Symbol, and I want it to accept a String > as well: > > function test(s::Symbol) > end > > What I want to do is say, "yes I know this is not a Symbol - so please > convert() it" > > mystr = "foo" > test(mystr::Symbol) > > This would translate to: > > mystr = "foo" > test(convert(Symbol, mystr)) > > Is there any such operator? I would have thought doing this with the > current type assert would make sense? > > Regards, Fil. > >
