我有一个非常简单/愚蠢的问题。
我有一个从火花数据框返回的变量,如下所示:
Any = WrappedArray(101, 11, 119, 141, 238, 64, 45, 268, 31, 63, 86, 23, 24, 420, ...
我想要做的就是把它作为一个普通的数组,所以我可以遍历整数。即使我可以将其设置为WrappedArray
类型,我也可以从那里获得数组。
答案 0 :(得分:1)
val w : WrappedArray[Int] = 1 to 10 toArray
val a : Any = w //a is now just like the variable you've got
//cast the Any to a Wrapped array. Probably want to do this inside a try/catch
val wrapped = a.asInstanceOf[WrappedArray[Int]]
wrapped.foreach{ i => println(i) }