3 ms·
Declaring a parameter as a `f: () -> int` instead of `f` requires that you think about what the signature needs to be. What if you don't know? (Java programmer
by reitanqild 9y ago
Declaring a parameter as a `f: () -> int` instead of `f` requires that you think about what the signature needs to be. What if you don't know?
(Java programmer here.) Then return a sufficiently "broad" type up to, if necessary, Object.
That said I almost never fall that far back, I'd see that as a sign that I should stop and think.
Oh, and the advantage of a typed languages like Java: you can have extremely good tool support. Netbeans (or IntelliJ or Eclipse) will happily help you to change types if it later turns out you were wrong.