The raw prefix can be used to tell to the compiler not to escape any characters in string. But why I get compilation error when I try to do like this?

raw"\d".r  // not escaped slash
有帮助吗?

解决方案

What version of Scala are you using? Works fine in 2.10.0:

Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_37).
Type in expressions to have them evaluated.
Type :help for more information.

scala> raw"\d".r
res0: scala.util.matching.Regex = \d
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top