Skip to content

Instantly share code, notes, and snippets.

@CodaFi
Forked from rbrockerhoff/bug.swift
Last active August 29, 2015 14:04
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 CodaFi/d570cc8ae44e379bab0a to your computer and use it in GitHub Desktop.
Save CodaFi/d570cc8ae44e379bab0a to your computer and use it in GitHub Desktop.
extension Array {
mutating func merge <S: SequenceType where S.Generator.Element == Element> (seq: S) {
var gen = seq.generate()
while let (key : Element, value : Element) = gen.next() {
self[0] = value
}
}
}
var arr = [0]
let more = [1,2,3]
arr.merge(more)
println(arr) //[140734546800128]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment