Following is the code snippet I am using from play with scala book. It works well in the framework but when I try in the commndline it gives the error
error: Product.type does not take parameters
var products = Set(Product(5018206244611L, "Tom", "Zebra"))
Below is the code I used
case class Product(ean: Long, name: String, description: String)
object Product {
var products = Set(Product(5018206244611L, "Tom", "Zebra"))
def findAll = products.toList.sortBy(_.ean)
}
In one of the controller file tutorial uses Product.apply and Product.unapply. What does Product.apply and Product.unapply indicate when they are not defined inside the object and gives me error when I type them in console. FOllowing is the code which uses Product.apply and Product.unapply
private val productForm: Form[Product] = Form(
mapping(
"ean" -> longNumber.verifying(
"validation.ean.duplicate", Product.findByEan(_).isEmpty),
"name" -> nonEmptyText,
"description" -> nonEmptyText)(Product.apply)(Product.unapply)
)