我的process
(修剪字符串列表)函数可以单独运行,但是当我在另一个函数内部调用时,行为会有所不同。
def process (s: Any*): String = {
val chaine= s.map(_.toString).toList
println(s" Convert to string: $chaine")
val trimmed = chaine.map(_.trim).toList
println(s"Trimmed: $trimmed")
trimmed.mkString(",")
}
def func(s: Any*): String = {
val processed = process(s)
processed
}
process("xyz ","111 ")
func("xyz ","111 ")
结果
Convert to string: List(xyz , 111 )
Trimmed: List(xyz, 111)
Convert to string: List(WrappedArray(xyz , 111 ))
Trimmed: List(WrappedArray(xyz , 111 ))