在 repl 中,这会引发异常,我不知道为什么。我真的很想了解这一点。
scala> (1 until 10000).foreach("%s%s".format("asdf", "sdff"))
java.lang.StringIndexOutOfBoundsException: String index out of range: 8
at java.lang.String.charAt(String.java:686)
at scala.collection.immutable.StringLike$class.apply(StringLike.scala:54)
at scala.collection.immutable.WrappedString.apply(WrappedString.scala:32)
at scala.collection.immutable.WrappedString.apply(WrappedString.scala:32)
at scala.collection.immutable.Range.foreach(Range.scala:75)