The raw interpolator

The final one pre-existing interpolator in Scala is the raw interpolator. This interpolator does not allow you to use any escape sequence characters in your string, it means that if you try to give an escape sequence character, it'll be treated as a normal literal and nothing more. The way we write raw interpolator is almost similar to the other two interpolators. We precede our String with a raw keyword and it works for us:

scala> val rawString = raw"I have no escape \n character in the String \n "
rawString: String = "I have no escape \n character in the String \n "

Here, in the string escape character, \n was treated as a normal literal, and in the resulting string it remained the same. In a normal string, \n would have converted into a newline character.

scala> val rawString = "I have no escape \n character in the String \n "
rawString: String =
"I have no escape
character in the String
"

Using this raw interpolator, we can avoid escape sequences. These constructs give us a way to write code more efficiently and concisely.