Tweak to collective extension syntax

Mark "Justin" Waks
1 min readJan 7, 2020

--

For those keeping track of the new extension methods feature: Martin has just submitted a PR that changes the way you express groups of these extensions. It was previously:

given listOps: [T](xs: List[T]) extended with {
def second = xs.tail.head
def third = xs.tail.tail.head
}

This PR switches that to:

extension listOps of [T](xs: List[T]) with {
def second = xs.tail.head
def third = xs.tail.tail.head
}

As usual, please bear in mind that this is just a PR, far from final. But I think it’s a good change. It better expresses what you intend — to add some extension methods — rather than focusing on the typeclass-centric given keyword. I think the jury is still out on the use of of here, but it seems to be a step in the right direction…

--

--

Mark "Justin" Waks
Mark "Justin" Waks

Written by Mark "Justin" Waks

Lifelong programmer and software architect, specializing in online social tools and (nowadays) Scala. Architect of Querki (“leading the small data revolution”).

No responses yet