Skip to content

Instantly share code, notes, and snippets.

@mmaz
Last active December 19, 2015 22:49
Show Gist options
  • Save mmaz/6030687 to your computer and use it in GitHub Desktop.
Save mmaz/6030687 to your computer and use it in GitHub Desktop.
scala Option to Guava Optional
import com.google.common.base.Optional
def toOptional[T](sop : Option[T]) : Optional[T] = Optional.fromNullable[T](sop.orNull[T])
//examples
toOptional(None)
toOptional(Some("dude"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment