3 ms·
Might as well just drop the var keyword altogether at that point. func foo(x: int, y: int): int { sum : int = x + y return x + y } Wit
by king_geedorah 2y ago
Might as well just drop the var keyword altogether at that point.
func foo(x: int, y: int): int {
sum : int = x + y
return x + y
}
With type inference the type declaration just collapses out to what you have now.
func foo(x: int, y: int): int {
sum := x + y
return x + y
}
I've seen it in a few languages and it has seemed quite nice in use and appearance to me.
- king_geedorah 2y agoWhoops. I've just realised those should both say return sum