Does Scala have a native way to count all occurrences of a character in a string?
If so, how do I do it?
If not, do I need to use Java? If so, how do I do
You can also take a higher level approach to look into substring occurrences within another string, by using sliding:
sliding
def countSubstring(str: String, sub: String): Int = str.sliding(sub.length).count(_ == sub)