Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created November 17, 2015 12:35
Show Gist options
  • Save fitomad/68e2a343cb5e592b9639 to your computer and use it in GitHub Desktop.
Save fitomad/68e2a343cb5e592b9639 to your computer and use it in GitHub Desktop.
extension CollectionType
{
/**
Construye una cadena de texto con los elementos contenidos
- parameter separator: Un caracter que se emplea para separar los elementos
*/
func descriptionWithSeparator(separator: String) -> String
{
return self.reduce(String())
{
if String($0).isEmpty
{
return String($1)
}
else
{
return "\(String($0))\(separator)\(String($1))"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment