I study Julia, so I'm a beginner. Now I am studying its strongly typed functions. I understand that I do not see the use of abstract types for arrays. Let me explain with an example:
Suppose I would like to create a function that accepts arrays of reals, regardless of their specific type. I would use:
function f(x::Array{Real})
This function can never be called without raising a f has no method matching f(::Array{Float64,1})
I would call f([1,2,3])
or f([1.,2.,3.])
, While the element type is Real.
I read that you can promote or convert an array (p.eg f(convert(Array{Real}, [1, 2, 3]))
or so), but I see that it is really non-dynamic and tedious.
Is there any other alternative, rather than getting rid of strongly typed behavior?
Thanks.
source share