Created
May 15, 2017 01:48
-
-
Save ps/a69706c3e93f46ea500545fe4781d2c9 to your computer and use it in GitHub Desktop.
Some(Int) vs just Int
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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