Problem description
Scala StringOps provides a lines
method that returns an Iterator[String]
.
Java 11 added lines()
with return type java.Stream[String]
.
In a chained method call like
val text: String
text.lines.foldLeft("")(_ + _)
the code will no longer compile and throw an exeption that foldLeft
is not defined on java.Stream[String].
As far as I understand the implicit resolution is no longer applied as the lines method now is already found in java.String.
How can I express that I want the implicit to be applied (the one without parens) isntead of the java.String.lines()
Additional info
- I found
linesIterator
but it is deprecated. - Downgrading is an option but is there a way around it.
val text : StringOps
looks realy ugly but solved it but I am unhappy with this solution