@josimar wrote:
Hi, when creating new functions in Julia, do I need to specify the input type of the arguments ? Is this required for speed or only for organization ?
For example, I would like to create a function that takes as input either an array or a scalar number. How would this be possible within the scope of Julia function definitions and code organization ?
I would prefer to specify the input type of my function for easy read of what it expect as input.
function printNumber(x::Array{Number}) println("value = ", x) end inputValue = 10.0 printNumber([inputValue]) # This works inputValue = 10 printNumber(inputValue) ## This fails
Posts: 4
Participants: 3