Skip to content

Instantly share code, notes, and snippets.

@vigneshwaranr
Created May 29, 2020 07:29
Show Gist options
  • Save vigneshwaranr/7c5580480cddc7de1a53102daef09081 to your computer and use it in GitHub Desktop.
Save vigneshwaranr/7c5580480cddc7de1a53102daef09081 to your computer and use it in GitHub Desktop.
9e8a12f2112b / MaybeDivideable / divide1
def divide1(a: Int, b: Int): MaybeDivideable = {
MaybeDivideable(a) match {
case UnDivideable =>
UnDivideable
case Divideable(x) =>
MaybeDivideable(b) match {
case UnDivideable =>
UnDivideable
case Divideable(y) =>
MaybeDivideable(x / y)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment