- 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.
- Google Flutter Mobile Development Quick Start Guide
- Java應用與實戰
- Hands-On Data Structures and Algorithms with JavaScript
- 認識編程:以Python語言講透編程的本質
- AngularJS Web Application Development Blueprints
- Linux命令行與shell腳本編程大全(第4版)
- R Deep Learning Cookbook
- Terraform:多云、混合云環境下實現基礎設施即代碼(第2版)
- Beginning C++ Game Programming
- 網絡數據采集技術:Java網絡爬蟲實戰
- Java EE架構設計與開發實踐
- 例解Python:Python編程快速入門踐行指南
- Hands-On ROS for Robotics Programming
- Django 3 Web Development Cookbook
- Python程序員面試算法寶典