0
鑑於一些情況下類Foo(x: Int)
和Bar(x: Int)
,一個(隱含的)功能f1
即轉換Foo => Bar
是有可能實現以下目標:是否可以提供從Iterable [T]到Iterable [U]的隱式轉換?
val foos: List[Foo] = List(Foo(1), Foo(2))
def myFunction(bar: List[Bar]) = ???
myFunction(foos) // Here foos should be implicitly converted from List[Foo] to List[Bar]
有關編寫隱函數從可迭代[T]轉換成什麼Iterable [U]使用隱式函數'f1'? – JoseM