For example in the following article
http://www.artima.com/weblogs/viewpost.jsp?thread=179766
Two separate examples are given:
- Automatic string conversion
- Addition of append method
Suppose I want to have automatic string conversion AND a new append method. Is this possible? I have been 开发者_Python百科trying to do both at the same time but I get compile errors. Does that mean the two implicits are conflicting?
You can have any number of implicit conversions from a class provided that each one can be unambiguously determined depending on usage. So the array to string and array to rich-array-class-containing-append is fine since String
doesn't have an append
method. But you can't convert to StringBuffer
which has append
methods which would interfere with your rich array append.
精彩评论