Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yuck, apparently I missed this happening. Its still (I think) true in java, where you can't have a function return `var`.



You're correct about Java. It was an explicit decision that the only local variable's type declarations and lambda parameters may be inferred with `var`.

This excludes, as you mentioned, the return types of a function, its parameter's types, as well as the types of fields in a class.


It’s only true if you have the function body available for deduction. Headers/decls need types.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: