Skip to content

Instantly share code, notes, and snippets.

@localshred
Created November 13, 2014 00:58
Show Gist options
  • Save localshred/958cbc26674bbb6d4079 to your computer and use it in GitHub Desktop.
Save localshred/958cbc26674bbb6d4079 to your computer and use it in GitHub Desktop.
erlang case statment pattern matching from http://learnyousomeerlang.com/syntax-in-functions#pattern-matching
beach(Temperature) ->
case Temperature of
{celsius, N} when N >= 20, N =< 45 ->
'favorable';
{kelvin, N} when N >= 293, N =< 318 ->
'scientifically favorable';
{fahrenheit, N} when N >= 68, N =< 113 ->
'favorable in the US';
_ ->
'avoid beach'
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment