質問

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