java-oo icon indicating copy to clipboard operation
java-oo copied to clipboard

Assignment operator overloading via constructors

Open amelentev opened this issue 11 years ago • 1 comments

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.

amelentev avatar May 27 '14 21:05 amelentev

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)

binkley avatar May 28 '14 07:05 binkley