Make42 Make42 - 2 months ago 9
Scala Question

What can I write after self reference arrow?

I understand what the result of a self type is as in

trait SpellChecker {
self: RandomAccessSeq[char] =>
...
}


from http://www.markthomas.info/blog/92

As far as I understand it says "the object instantiated from this trait is also of type
RandomAccessSeq[char]
". Is that right?

My question: What can I write after the
=>
and what does it mean? I noticed I don't get a compiler error when writing
AnyRef
after the
=>
.

Answer

My question: What can I write after the =>

Anything.

and what does it mean?

It denotes the end of the self-type annotation. After that comes the normal trait body, just like as if the self-type annotation wasn't even there.