Search code examples
scalaprogramming-languages

What exactly does this snippet do in scala?


I'm trying to understand the twitter gizzard example rowz, and I can't figure out what this little snippet does in scala:

package com.twitter.rowz
import com.twitter.gizzard.nameserver.{Forwarding, NameServer}
import com.twitter.gizzard.shards.ShardException

class ForwardingManager(nameServer: NameServer[Shard]) extends (Long => Shard) {  
    def apply(id: Long) = nameServer.findCurrentForwarding(0, id)
}

what exactly is the class extending?


Solution

  • (A=>B) is Function1[A,B]

    Those lines are strictly equivalent:

    class ForwardingManager(nameServer: NameServer[Shard]) extends (Long => Shard)
    class ForwardingManager(nameServer: NameServer[Shard]) extends Function1[Long,Shard]