- Learning Scala Programming
- Vikash Sharma
- 194字
- 2021-06-30 19:07:53
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.
- Apache Oozie Essentials
- Mastering Zabbix(Second Edition)
- C#編程入門指南(上下冊)
- Learning Bayesian Models with R
- Scratch 3游戲與人工智能編程完全自學教程
- Apache Karaf Cookbook
- Java Web程序設計任務教程
- 學習正則表達式
- Getting Started with Greenplum for Big Data Analytics
- Mastering Android Game Development
- Java程序設計入門
- jQuery Mobile移動應用開發實戰(第3版)
- 代碼閱讀
- scikit-learn Cookbook(Second Edition)
- 30天學通C#項目案例開發