我打电话tail
给Array
,但看到一个警告。
scala> val arr = Array(1,2)
arr: Array[Int] = Array(1, 2)
scala> arr tail
warning: there were 1 feature warning(s); re-run with -feature for details
res3: Array[Int] = Array(2)
用于Array的Scaladocs显示了一个UnsupportedOperationException [will be thrown]
if the mutable indexed sequence is empty.
是否有一种安全、不会抛出异常的方法来获取数组的尾部?