den bardadym den bardadym - 1 year ago 178
Scala Question

Scala with keyword usage

I found simple example:

class Post extends LongKeyedMapper[Post] with IdPK {
def getSingleton = Post

object title extends MappedText(this)
object text extends MappedText(this)
object date extends MappedDate(this)

object Post extends Post with LongKeyedMetaMapper[Post] {
def getPosts(startAt: Int, count: Int) = {
Post.findAll(OrderBy(, Descending), StartAt(startAt), MaxRows(count))

def getPostsCount = Post.count

What does it mean
with IdPK


Answer Source

with means that the class is using a Trait via mixin.

Post has the Trait IdPK (similar to a Java class can implements an Interface).

See also A Tour of Scala: Mixin Class Composition

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download