Skip to content

Instantly share code, notes, and snippets.

@jakubjanecek
Created February 10, 2013 13:11
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 jakubjanecek/4749542 to your computer and use it in GitHub Desktop.
Save jakubjanecek/4749542 to your computer and use it in GitHub Desktop.
def genericSize(obj: AnyRef): Int = obj match {
case x: String => x.length
case x: Array[AnyRef] => x.length
case x: List[AnyRef] => x.size
case x: ObjectWithSize => x.count
case _ => -1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment