Skip to content

Instantly share code, notes, and snippets.

@knightpop
Created September 9, 2017 18:10
Show Gist options
  • Save knightpop/a385f1323d64395bbbbad3fad2554406 to your computer and use it in GitHub Desktop.
Save knightpop/a385f1323d64395bbbbad3fad2554406 to your computer and use it in GitHub Desktop.
def getUserIdOrDeviceIdOrCarSerialId(
id: Either[UserId, Either[DeviceUuid, CarSerialId]]
): Long = id match {
case Left(userId) => userId + 1
case Right(Left(deviceUuid)) => deviceUuid + 2
case Right(Right(carSerialId)) => carSerialId + 3
}
getUserIdOrDeviceIdOrCarSerialId(Left(taggedUserId))
getUserIdOrDeviceIdOrCarSerialId(Right(Left(taggedDeviceUuid)))
getUserIdOrDeviceIdOrCarSerialId(Right(Right(taggedCarSerialId)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment