Skip to content

Instantly share code, notes, and snippets.

@ElectricCoffee
Last active August 29, 2015 13:58
Show Gist options
  • Save ElectricCoffee/10018292 to your computer and use it in GitHub Desktop.
Save ElectricCoffee/10018292 to your computer and use it in GitHub Desktop.
simple class enrichment for Seq, that allows you to perform boolean comparisons on them, these comparisons compare the sizes of the lists
// it's Seq[_] because we don't really care abou the type, all we're doing is comparing sizes anyway
implicit class RichSequence(a: Seq[_]) {
def ==(b: Seq[_]): Boolean = a.size == b.size
def !=(b: Seq[_]): Boolean = !(a == b)
def < (b: Seq[_]): Boolean = a.size < b.size
def <=(b: Seq[_]): Boolean = a < b || a == b
def > (b: Seq[_]): Boolean = !(a <= b)
def >=(b: Seq[_]): Boolean = !(a < b)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment