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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top