@transient lazy val field serialization
I have a problem on Scala. I serialize an instance of class with @transient lazy val field. And then I deserialize it, the field is assigned null . I expect the lazy evaluation after deserialization. What should I do? Following is a sample code. object Test { def main(args: Array[String]){ //---------------- // ClassA - with @transient //---------------- val objA1 = ClassA("world"); println(objA1); // This works as expected as follows: // "Good morning." // "Hello, world" saveObject("testA.dat", objA1); val objA2 = loadObject("testA.dat").asInstanceOf[ClassA]; println(objA2); // I expect this