Avoiding implicit def ambiguity in Scala

后端 未结 6 1322
悲哀的现实
悲哀的现实 2021-01-07 23:27

I am trying to create an implicit conversion from any type (say, Int) to a String...

An implicit conversion to String means RichString methods (like reverse) are not

6条回答
  •  情话喂你
    2021-01-08 00:00

    Either make a huge proxy class, or suck it up and require the client to disambiguate it:

    100.asInstanceOf[String].length

提交回复
热议问题