- 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.
- JavaScript從入門到精通(微視頻精編版)
- GAE編程指南
- Responsive Web Design with HTML5 and CSS3
- MySQL數(shù)據(jù)庫管理與開發(fā)(慕課版)
- Bootstrap 4:Responsive Web Design
- 精通MATLAB(第3版)
- Instant Lucene.NET
- SQL Server 2016 從入門到實戰(zhàn)(視頻教學(xué)版)
- 編程改變生活:用Python提升你的能力(進階篇·微課視頻版)
- Three.js權(quán)威指南:在網(wǎng)頁上創(chuàng)建3D圖形和動畫的方法與實踐(原書第4版)
- DevOps 精要:業(yè)務(wù)視角
- Go Systems Programming
- Instant SQL Server Analysis Services 2012 Cube Security
- C語言從入門到精通(第4版)
- 深入淺出Go語言核心編程