Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot pickle Array but can pickle List in Scala with Pickling
    primarykey
    data
    text
    <p>I wrote this method:</p> <pre><code> def serialize(obj: Array[Track], file: File) { val pickle = obj.pickle; println(pickle.toString()); val writer = new PrintWriter(file); writer.write(pickle.toString()); writer.flush(); } </code></pre> <p>which gives me this error: </p> <pre><code>Exception in thread "main" java.lang.AssertionError: assertion failed at scala.Predef$.assert(Predef.scala:165) at scala.pickling.ReactMap.insertIfNotThere(ReactMap.scala:55) at scala.pickling.internal.package$.lookupPicklee(package.scala:106) at BillboardsHot100$TrackPickler1$2$.pickle(Billboards.scala:46) at BillboardsHot100$TrackPickler1$2$.pickle(Billboards.scala:46) at scala.pickling.LowPriorityPicklersUnpicklers$$anon$1$$anonfun$pickle$1$$anonfun$apply$1.apply(Custom.scala:109) at scala.pickling.LowPriorityPicklersUnpicklers$$anon$1$$anonfun$pickle$1$$anonfun$apply$1.apply(Custom.scala:107) at scala.pickling.json.JSONPickleBuilder.putElement(JSONPickleFormat.scala:145) at scala.pickling.LowPriorityPicklersUnpicklers$$anon$1$$anonfun$pickle$1.apply(Custom.scala:107) at scala.pickling.LowPriorityPicklersUnpicklers$$anon$1$$anonfun$pickle$1.apply(Custom.scala:106) at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33) at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:34) at scala.pickling.LowPriorityPicklersUnpicklers$$anon$1.pickle(Custom.scala:106) at BillboardsHot100.serialize(Billboards.scala:46) at BillboardsHot100.checkForChanges(Billboards.scala:40) at Main$.main(Main.scala:5) at Main.main(Main.scala) </code></pre> <p>But if I change the required to type to List[Track] and just call toList before calling it, it works perfectly. Track is this case class:</p> <pre><code>case class Track(title: String, artist: String) { override def toString() = title + ", " + artist; } </code></pre> <p>Am I doing something wrong or is this a limitation of pickling?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload