Lar*_*ren 5 syntax scala notation
在Scala中使用regexp时我写了这样的东西:
scala> val y = "Foo"
y: java.lang.String = Foo
scala> y "Bar"
scala>
Run Code Online (Sandbox Code Playgroud)
如您所见,第二个语句只是默默接受.这是合法的法律声明,如果是,它会做什么?或者它是解析器中的错误,应该有错误消息?
这确实是解析器中的错误.它在scala 2.7.2(目前是RC6)中修复
$ ./scala
Welcome to Scala version 2.7.2.RC6 (Java HotSpot(TM) Client VM, Java 1.5.0_16).
Type in expressions to have them evaluated.
Type :help for more information.
scala> def y = "foo"
y: java.lang.String
scala> y "bar"
<console>:1: error: ';' expected but string literal found.
y "bar"
^
scala> val x = "foo"
x: java.lang.String = foo
scala> x "foo"
<console>:1: error: ';' expected but string literal found.
x "foo"
^
scala> "foo" "bar"
<console>:1: error: ';' expected but string literal found.
"foo" "bar"
^
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
677 次 |
| 最近记录: |