3 ms·
Note1: Type hints are hints for the reader. If you cleverly discovered that your function is handling any type of data, hint that! Note2: From my experience, i
by lolive 1y ago
Note1:
Type hints are hints for the reader.
If you cleverly discovered that your function is handling any type of data, hint that!
Note2: From my experience, in Java, i have NEVER seen a function that consumes explicitely an Object. In Java, you always name things. Maybe with parametric polymorphism, to capture complex typing patterns.
Note 3: unfortunately, you cannot subclass String, to capture the semantic of its content.
- 1313ed01 1y ago> Java, i have NEVER seen a function that consumes explicitely an Object So you did not see any Java code from before version 5 (in 2004) then, because the language did not have generics for the first several years it was popular. And of course many were stuck working with older versions of the language (or variants like mobile Java) without generics for many years after that.
- lolive 1y agoExactly, I have never seen such codes [*]. Probably because the adoption of the generics has been absolutely massive in the last 20 years. And I expect the same thing to eventually happen with Typescript and [typed] Python. [*]: nor have I seen EJB1 or even EJB2. Spring just stormed them, in the last 20 years.
- sfn42 1y agoAn example of a function in Java that consumes a parameter of type Object is System.out.println(Object o) Many such cases.