我的以下代码有错误,我不明白为什么编译器在两种选择之间找不到好的方法:
scala> import java.nio.file.Paths
scala> val paths = List("a","b","c")
scala> Paths.get(paths:_*)
<console>:33: error: overloaded method value get with alternatives:
(x$1: java.net.URI)java.nio.file.Path <and>
(x$1: String,x$2: <repeated...>[String])java.nio.file.Path
cannot be applied to (String)
Paths.get(paths:_*)
^
我找到了以下解决方法,但是有一种更干净的方法吗?
scala> Paths.get("", paths:_*)
res5: java.nio.file.Path = a/b/c
Paths.get(paths.head,paths.tail:_*)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句