Skip to content

Instantly share code, notes, and snippets.

@kolemannix
Created November 29, 2018 13:06
Show Gist options
  • Save kolemannix/4bd1ebcc779d219f00e17176eabda836 to your computer and use it in GitHub Desktop.
Save kolemannix/4bd1ebcc779d219f00e17176eabda836 to your computer and use it in GitHub Desktop.
case class Point(x: Int, y: Int)
val serializePoint = { point: Point => s"${point.x},${point.y}".getBytes("UTF-8") }
val deserializePoint = { bytes: Array[Byte] =>
val x :: y :: Nil = new String(bytes, "UTF-8").split(",").toList.map(_.toInt)
Point(x, y)
}
val point = Point(3, 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment