I find this kind of code is very common in Lift framework, written like this: object BindHelpers extends BindHelpers {}
What does this mean?
In this case, BindHelpers
is a trait and not a class. Let foo()
to be a method defined in BindHelpers
, to access it you can either.
Use it through the companion object: BindHelpers.foo()
Mix the trait BindHelpers
in a class and thus be able to access the methods inside of it.
For instance:
class MyClass extends MyParentClass with BindHelpers {
val a = foo()
}
The same techniques is used in Scalatest for ShouldMatchers
for instance.
You can find David Pollak's answer to the same question in the liftweb group.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With