Skip to content

Instantly share code, notes, and snippets.

@davidstump
Created August 18, 2014 23:15
Show Gist options
  • Save davidstump/a9ec98497b741b0a5e80 to your computer and use it in GitHub Desktop.
Save davidstump/a9ec98497b741b0a5e80 to your computer and use it in GitHub Desktop.
Swift and Elixir
// Elixir
case {1, 2, 3} do
{4, 5, 6} ->
"This clause won't match"
{1, x, 3} ->
"This clause will match and bind x to 2 in this clause"
_ ->
"This clause would match any value"
end
// Swift
switch (1, 2, 3) {
case (4, 5, 6):
println("This clause won't match")
case (1, let x, 3):
println("This clause will match and bind x to 2 in this clause")
case _:
println("This clause will match any value")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment