This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 1.1, “Testing String Equality in Scala.”
When using Scala, you want to compare two strings to see if they’re equal, i.e., whether they contain the exact same sequence of characters.
In Scala you compare two String instances with the
== operator. Given these strings: