- 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.
- Spring Boot開發(fā)與測試實(shí)戰(zhàn)
- 構(gòu)建移動(dòng)網(wǎng)站與APP:HTML 5移動(dòng)開發(fā)入門與實(shí)戰(zhàn)(跨平臺移動(dòng)開發(fā)叢書)
- Rust Essentials(Second Edition)
- C語言程序設(shè)計(jì)
- Scala程序員面試算法寶典
- 基于SpringBoot實(shí)現(xiàn):Java分布式中間件開發(fā)入門與實(shí)戰(zhàn)
- Visual FoxPro 6.0程序設(shè)計(jì)
- 從Power BI到Analysis Services:企業(yè)級數(shù)據(jù)分析實(shí)戰(zhàn)
- SQL Server 2008中文版項(xiàng)目教程(第3版)
- Flink核心技術(shù):源碼剖析與特性開發(fā)
- Monitoring Docker
- Wearable:Tech Projects with the Raspberry Pi Zero
- Learning iOS Penetration Testing
- PHP程序設(shè)計(jì)經(jīng)典300例
- jQuery EasyUI從零開始學(xué)