The code below shows warning, why? And how to implement it without warning?
An imported function has been extended without using
module defined typed arguments.Julia(TypePiracy)
import Base: fill
fill(f::Function, length::Int) = [f(i) for i in 1:length] # <= warn
println(fill(1, 3))
println(fill((i) -> i^2, 3))
P.S.
Also, is there a way to differentiate fn with single int arg and no args, to make following code work:
println(fill(1, 3))
println(fill((i) -> i^2, 3))
println(fill(() -> 1, 3)) # <= Error
5