Because implicits don't work like this. You have a conversion from (Int, Option[Date], Option[String], Option[Date], Option[Boolean], Option[Boolean],
Option[Boolean], Option[Boolean], Option[String])
to Store
, but you want a conversion from Store => Unit
to (Int, Option[Date], Option[String], Option[Date], Option[Boolean], Option[Boolean],
Option[Boolean], Option[Boolean], Option[String]) => Unit
:
// just to simplify
type StoreTuple = (Int, Option[Date], Option[String], Option[Date],
Option[Boolean], Option[Boolean], Option[Boolean], Option[Boolean], Option[String])
// uses the conversion you've already defined
implicit def convertLambdasWithStoreArguments[A](f: Store => A): StoreTuple => A =
tuple => f(tuple)
But then you may find that you need, e.g. conversion from List[StoreTuple]
to List[Store]
, from Map[Store, A]
to Map[StoreTuple, A]
, and so on.
Instead of defining all these additional conversions, you may use your existing one and write
ls.foreach { s => val store: Store = s; println(store.toString) }
instead. Or
ls.foreach { s => println(s.asString) }
where asString
is a method of Store
. Note that
ls.foreach { s => println(s.toString) }
won't work since Tuple9
already has a toString
method.