Scala relies on java.lang.String for it's String operations, however, it enriches the java string class by adding other methods such as .intersect among others Same goes for the int wrapper (Int) in java, there's also the RichInt class.
I realize that the following code:
val stringOne: String = "teststring"
val stringTwo: String = "string"
stringOne.intersect(stringTwo)
will cause the scala compiler to kind of cast stringOne to the StringOps class so that it has access to method intersect
I'm concerned that this could result in serious computational costs So can anyone tell me if this is true and if so, are there ways to optimize or avoid this situation?
I hope my question makes sense, i have read several books, but none addresses these concerns Thanks. :)
EDIT: A similar question has been asked and answered here I would appreciate it if anyone could address this from the memory angle as well