Created
August 22, 2011 07:23
-
-
Save sidharthkuruvila/1161849 to your computer and use it in GitHub Desktop.
An Option in scala can prepended to a List using the ++: concatenation operator.
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
def canReturnNone = Some(1) | |
println(canReturnNone ++: List(2,3,4)) | |
//prints: List(1, 2, 3, 4) | |
def canReturnNone = None | |
println(canReturnNone ++: List(2,3,4)) | |
//prints: List(2, 3, 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment