我注意到了这一点:
val word = "My word"
println(word.substring(0,1000))
在Scala小提琴中工作得很好:here
但是在生产环境中运行时会抛出ArrayIndexOutOfBounds异常。为什么在小提琴中允许这样做,它是Scala版本吗?我在Scala 2.12中测试了我的生产代码。
答案 0 :(得分:2)
看起来像JVM vs JS的区别。请参阅"未定义的行为" http://www.scala-js.org/doc/semantics.html的一节; ArrayIndexOutOfBoundsException
和StringIndexOutOfBoundsException
都已列出。