java-oo
java-oo copied to clipboard
Assignment operator overloading via constructors
Assignment operator overloading now works only via static valueOf method.
In cases we can't add valueOf method to a class we may use constructors:
BigDecimal a = "123"
will be transformed to
BigDecimal a = new BigDecimal("123")
(there is no valueOf(String) method in j.m.BigDecimal)
But this will add more ambiguity.
I would expect, in general, any of these might work:
Option<T> maybe = T-instance; // assigns Option.of(T-instance)
T instance = U-instance; // assigns new T(U-instance)