Time for action – Saving the list

In order to save the list, we will serialize it and save the result in a file. This indeed is certainly not the best way to do things but in our case, it will be enough.

   public static function save()
   {
      php.io.File.putContent("zookeeper.data", haxe.Serializer.run(animals));
   }

Very simple, isn't it? We are simply serializing the animals list and dumping the result directly in the zookeeper.data file.

Get haXe 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.