Most simple way of appending values inside [String : [Int]]

Updated
Dec 17, 2019 8:20 AM
Created
Dec 17, 2019 8:19 AM
Tags
SwiftMemo
Keywords

var buffer: [String : [Int]] = [:]

better: do {
  buffer["hello", default: []].append(contentsOf: [1,2,3])
  buffer["hello"]
}

basic: do {
  
  if let _ = buffer["abc"] {
    buffer["abc"]!.append(contentsOf: [1,2,3])
  } else {
    let c = [1,2,3]
    buffer["abc"] = c
  }
  
}

buffer