Scala application definition error : not found : value ~

1.1k views Asked by At

enter image description here

Error message : not found : value ~

Any help ?

=== EDIT ===

Actual code :

val rowParser: RowParser[Category] = { long("id") ~ str("name") ~ str("description") ~ long("parent_id") map { case id ~ name ~ description ~ parent_id => Category(id, name, description, Category(parent_id)) } }

Imports:

package models

import anorm.RowParser
import anorm.SQL
import anorm.SqlParser.long
import anorm.SqlParser.str
import anorm.sqlToSimple
import anorm.toParameterValue
import play.api.Play.current
import play.api.db.DB
import play.api.libs.json.Json
import play.api.libs.json.Json.toJsFieldJsValueWrapper
import play.api.libs.json.Writes
1

There are 1 answers

4
Shyamendra Solanki On BEST ANSWER

You need to import ~ class from anorm package.

import anorm.~

This class takes two params:

final case class ~[+A, +B](_1: A, _2: B) extends Product with Serializable

So it can be used with infix syntax in pattern matching:

A ~ B is same as ~(A, B)