As input for a function, I need a Vector with values greater than or equal to zero.
I tried l = Array{>:UInt8, 1}
However push!(l, 9
) throws an error.
MethodError: no method matching push!(::Type{Vector{>:UInt8}}, ::Int64)
What is the right way to define such an array?
Use case:
function concatenate_integers(l::Array{Int, 1})
"""
concatenate_numbers([3, 4, 5]) == 345
"""
@assert all(i -> i ∈ 0:9, l) "Only integers in range 0:9 are valid"
s = 0 # sum
for (i, n) in enumerate(reverse(l))
s += n * 10^(i-1)
end
return s
end
I would like to replace the all(i -> i ∈ 0:9, l)
part by enforcing the right input type.