Skip to content

Instantly share code, notes, and snippets.

@DominikPalo
Created October 15, 2021 13:14
Show Gist options
  • Save DominikPalo/6f425c90e69cf3209cbae6d0cef24b4c to your computer and use it in GitHub Desktop.
Save DominikPalo/6f425c90e69cf3209cbae6d0cef24b4c to your computer and use it in GitHub Desktop.
A Swift extension for an array containing name-value tuples to get the value of the first tuple found by name
fileprivate extension Array where Element == (String, String) {
func firstValue(name: String) -> String? {
if let tuple = self.first(where: {$0.0 == name}) {
return tuple.1
}
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment