I'm trying to use scala-pickling because at site github it seems so easy and clean. But, I'm failing in use it in this simple REPL:
scala> import scala.pickling._
import scala.pickling._
scala> import scala.pickling.Defaults._
import scala.pickling.Defaults._
scala> import binary._
import binary._
scala> class Xpto { var a = 0D; var b = 0 }
defined class Xpto
scala> val v = new Xpto { a = 1.23; b = 5 }
v: Xpto = $anon$1@636d2b03
scala> v.pickle
<console>:19: error: type mismatch;
found : v.type (with underlying type Xpto)
required: ?{def pickle: ?}
Note that implicit conversions are not applicable because they are ambiguous:
both method PickleOps in package pickling of type [T](picklee: T)pickling.PickleOps[T]
and method pickleOps in trait Ops of type [T](picklee: T)scala.pickling.PickleOps[T]
are possible conversion functions from v.type to ?{def pickle: ?}
v.pickle
^
<console>:19: error: value pickle is not a member of Xpto
v.pickle
^
What is wrong?
I did access other issues on StackOverflow with this same type of question, for example:
Scala pickling: Simple custom pickler for my own class?
Obs.: I'm using this reference in build.sbt:
"org.scala-lang.modules" %% "scala-pickling" % "0.10.1"
Great! It runs!
I started a new fresh scala console.
I was using this reference to scala.pickling in build.sbt:
and now I'm using
I'm also utilising Scala 2.11.6
Now it works perfectly, and really it's so simple.
I don't now if my others libraries references was generating that ambiguous refence. My references in build.sbt are:
Thanks to Markus.