Skip to content

Instantly share code, notes, and snippets.

@kourge
Created June 4, 2014 21:19
Show Gist options
  • Save kourge/38c1d3a07a5dee9407c0 to your computer and use it in GitHub Desktop.
Save kourge/38c1d3a07a5dee9407c0 to your computer and use it in GitHub Desktop.
Fun with double arrow / hash rocket in Swift
operator infix => { associativity left }
func => <K : Hashable, V>(key: K, value: V) -> (K, V) {
return (key, value)
}
let pairs: (String, Int)[] = [
"e" => 10,
"t" => 7,
"i" => 2
]
@kourge
Copy link
Author

kourge commented Jun 5, 2014

Swift seems to have no problem with it if you leave out associativity but every mention of custom infix operators in the docs declares associativity out of convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment