我想知道这是否:
object Foo {
val regex = "some complex regex".r
def foo() {
// use regex
}
}
和这个:
object Foo {
def foo() {
val regex = "some complex regex".r
// use regex
}
}
会有任何性能差异。即,scala 编译器会识别这"some complex regex".r
是一个常量并缓存它,这样它就不会每次都重新编译?