Skip to content

Instantly share code, notes, and snippets.

@sidharthkuruvila
Created August 22, 2011 07:23
Show Gist options
  • Save sidharthkuruvila/1161849 to your computer and use it in GitHub Desktop.
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.
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