I would like to know what is the exact difference between a class snippet and an object snippet in lift.
If I have
class Foo {
var a: String
def render(n:NodeSeq) = {
<h3> you chose {a} </h3>
}
}
and
object Bar {
var b: String
def render(n:NodeSeq) = {
<h3> you chose {b} </h3>
}
}
What is the concrete difference between them, do a
and b
have a different behaviour.
In simply lift it is said that
In this case, the snippet is an object singleton because it does not take any constructor parameters and has no instance variabled.
So does it mean that for every user, Bar
will be the same?
I know that it is a noob question, however I need to be very clear on this and I don't match well the difference between objects and classes in snippets.
See this page.
Basically, a new instance of Foo will be created for each http request (so there will be many existing at the same time), but only one instance of Bar will ever exist at the same time.
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