by lmm · 12y ago · 0 comments
trait Foo {
def bar(): Int
}
and 3rd party library had final class FooBar extends java.lang.Object {
public int bar() { /** **/ }
}
you could simply define your methods to take in a: type BarAble = { def bar():Int }
But obviously if the library class is not final, you can simply do: type ThirdPartyFoo = FooBar with Foo
ThirdPartyFoo <: FooIt's a feature that you will use directly maybe once a year when adding it to a library, but I then use that library (and indirectly that feature) virtually every day. YMMV but we've found it very useful.
(That's the answer I'd give if someone asked me this question)