Skip to content

Instantly share code, notes, and snippets.

@ps
Created May 15, 2017 01:48
Show Gist options
  • Save ps/a69706c3e93f46ea500545fe4781d2c9 to your computer and use it in GitHub Desktop.
Save ps/a69706c3e93f46ea500545fe4781d2c9 to your computer and use it in GitHub Desktop.
Some(Int) vs just Int
// implementation 1
object Users {
var users: Seq[User] = Seq()
def delete(id: Long) : Option[Int] = {
val originalSize = users.length
this.users = users.filterNot(_.id == id)
Some(originalSize - users.length)
}
}
// implementation 2
object Users {
var users: Seq[User] = Seq()
def delete(id: Long) : Int = {
val originalSize = users.length
this.users = users.filterNot(_.id == id)
originalSize - users.length
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment