Skip to content

Instantly share code, notes, and snippets.

@taisukeoe
Created February 21, 2015 13:36
Show Gist options
  • Save taisukeoe/a5e69b9b274def16cc7c to your computer and use it in GitHub Desktop.
Save taisukeoe/a5e69b9b274def16cc7c to your computer and use it in GitHub Desktop.
パターンマッチの網羅性チェックとifガード節
scala> def func(s:Option[String]) = s match{case Some(x) if x.size > 0 => x}
func: (s: Option[String])String
scala> def func(s:Option[String]) = s match{case Some(x) => x}
<console>:7: warning: match may not be exhaustive.
It would fail on the following input: None
def func(s:Option[String]) = s match{case Some(x) => x}
^
func: (s: Option[String])String
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment