Domanda

The following code fails due to "could not find implicit value for rs":


import scalikejdbc.WrappedResultSet

object DatabaseSupport {
  implicit class WrappedResultSetConverter(columnName: String)(implicit rs: WrappedResultSet) extends AnyRef {
    def stringCol: String = rs.string(columnName)
    def intCol: Int = rs.int(columnName)
  }

  def myTest(rsParam: WrappedResultSet) {
      val a: String = "name".stringCol
      val b: String = WrappedResultSetConverter("name").stringCol
  }
}

I had thought that the rsParam parameter to myTest would be visible to the implicits?

È stato utile?

Soluzione

It is not visible because it is explicit, it should be made implicit via the implicit keyword.

On the other hand, implicit parameters can be passed as explicit ones to methods.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top