#1924 How to serialize a class with a Map and a List?

detroitmatt Tue 19 Jun 2012

class Foo
{
  [Str:Int] thing1 := [:]
  Str[] thing2 := [,]
}

If I wanted to make Foo serializable, how would I implement each and add? The types overlap between thing2 and thing1, and iterating over thing1 only touches the Ints. Is it possible?

SlimerDude Tue 19 Jun 2012

@Serializable
class Foo {
  [Str:Int] thing1 := [:]
  Str[] thing2 := [,]
}

And don't bother with each or add.

Setting collection=true is just for pretty printing your string when your class doesn't contain anything else.

detroitmatt Tue 19 Jun 2012

Well that's easy (but that seems to be the slogan for Fantom). Thanks! Odd that we'd have the ability to specify a class as a collection when we don't really have the ability to build new collections (due to the lack of generics).

Login or Signup to reply.