Skip to content

Instantly share code, notes, and snippets.

@arturaz
Created September 22, 2013 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arturaz/6658543 to your computer and use it in GitHub Desktop.
Save arturaz/6658543 to your computer and use it in GitHub Desktop.
Matching ADT with Scala
private def getLeaderboardName(kind: Kind, lbKind: LeaderboardKind) = kind match {
case kg @ Kind.Global =>
LeaderboardName(s"lb_${leaderboardKindToString(lbKind)}", lbKind)
case Kind.World(w) =>
LeaderboardName(s"lb_w${w}_${leaderboardKindToString(lbKind)}", lbKind)
case Kind.Level(w, l, b) =>
LeaderboardName(
s"lb_w${w}_l$l${if (b) "b" else "")}_${leaderboardKindToString(lbKind)}",
lbKind
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment