den bardadym den bardadym - 13 days ago 9x
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



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