3 ms·
So as i understand it the 'use case' is for coercing 3rd party types into your own type hierarchy. Suppose you had: trait Foo { def bar(): Int } and 3
by octo_t 13y ago
So as i understand it the 'use case' is for coercing 3rd party types into your own type hierarchy. Suppose you had:
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 <: Foo