Skip to content

Instantly share code, notes, and snippets.

@kaja47
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaja47/482a80a4054bb4572cc5 to your computer and use it in GitHub Desktop.
Save kaja47/482a80a4054bb4572cc5 to your computer and use it in GitHub Desktop.
scala vs. swift (round 1)
let yetAnotherPoint = (1, -1)
switch yetAnotherPoint {
case let (x, y) where x == y:
println("(\(x), \(y)) is on the line x == y")
case let (x, y) where x == -y:
println("(\(x), \(y)) is on the line x == -y")
case let (x, y):
println("(\(x), \(y)) is just some arbitrary point")
}
val yetAnotherPoint = (1, -1)
yetAnotherPoint match {
case (x, y) if x == y =>
println(s"(${x}, ${y}) is on the line x == y")
case (x, y) if x == -y =>
println(s"(${x}, ${y}) is on the line x == -y")
case (x, y) =>
println(s"(${x}, ${y}) is just some arbitrary point")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment