Is there any documentation on the "outer =>" feature? It looks like a self type annotation with an infered type. However I have the feeling that I am wrong.
If it would be the case, is it only a different way to express access to super
?
trait A extends (B => C) {
outer =>
def apply(x: B): C = outer(x)
}
adjective. situated on or toward the outside; external; exterior: outer garments; an outer wall. situated farther out or farther from the center: the outer reaches of space.
The outermost parts or boundary of an area or object. perimeter. boundary. border. confines.
out·skirt ˈau̇t-ˌskərt. : a part remote from the center : border. usually used in plural. on the outskirts of town.
coming from or happening in a different state.
Not super
, but the outer scope. It's a way to aliasing different scopes. For example:
class A(val x:Int) { thisA =>
class B {
val x = 2
val y = x + thisA.x // without thisA how could we use A.x instead of B.x ? (*)
}
}
There is a better illustration here.
(*) There exist another way to have the same effect, but it's beyond this question.
It is a different way to access this
. It is useful in cases where an outer this
would be shadowed by another this
in an inner class. That way, you can just give the outer this
an additional (the original this
would still be available when it is in scope so it’s not a renaming) name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With