Quantcast
Channel: equality
Viewing all articles
Browse latest Browse all 10

How to test String equality in Scala

$
0
0

How to test String equality in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 1.1, “Testing String Equality in Scala.”

Problem

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.

Solution

In Scala you compare two String instances with the == operator. Given these strings:


Viewing all articles
Browse latest Browse all 10

Trending Articles