What is the best way to use the enrichment library in scala?

These are two different ways to implement it.

One shorter

implicit def toR1(s:String) = new { def getLength = s.length)} 

The second is longer

 class R2(s:String){def getLength2 = s.length)} implicit def toR2(s:String) = new R2(s) 

Which one is better?

+6
source share

Source: https://habr.com/ru/post/909125/


All Articles