Skip to content

Instantly share code, notes, and snippets.

@erdemildiz
Created July 19, 2021 11:04
Show Gist options
  • Save erdemildiz/a96ee98b7853fc9eb8de0064f89e1238 to your computer and use it in GitHub Desktop.
Save erdemildiz/a96ee98b7853fc9eb8de0064f89e1238 to your computer and use it in GitHub Desktop.
// 1. Method
let combinedName = names.reduce(""){ initialText, nextName in "\(initialText) \(nextName)"}
// 2. Method
let combinedName = names.reduce("", +)
// 3. Method
let combinedName = numbers.reduce("") { $0 + $1 }
// Result
// MynameisTom
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment