title: Set (Collection) - Insert multiple elements
body: <p><a href="https://developer.apple.com/documentation/swift/set?changes=latest_minor" rel="noreferrer">Set</a> is an unordered collection of unique elements. Almost similar to array.</p>
  
  <p>I want to add/insert multiple elements in a <code>Set</code> of <code>String</code>. But there is only single method provided that can insert only one element (accepts single Set element as a parameter argument) and I've collection of string (id).</p>
  
  <p><a href="https://developer.apple.com/documentation/swift/set/1541375-insert?changes=latest_minor" rel="noreferrer">insert(_:)</a></p>
  
  <pre><code>@discardableResult mutating func insert(_ newMember: Set.Element) -&gt; (inserted: Bool, memberAfterInsert: Set.Element)
  </code></pre>
  
  <p>How can I do that?</p>
  
  <p><strong>What I've tried:</strong>
  <br>I tried to create an extension very similar to <code>insert(_:)</code> method but it can accept multiple Set elements. It would be same as use of iteration over collection but don't need to handle it manually everywhere. </p>
  
  <pre><code>extension Set {
  
      @discardableResult mutating func insert(_ newMembers: [Set.Element]) -&gt; (inserted: Bool, memberAfterInsert: Set.Element) {
  
          newMembers.forEach { (member) in
              self.insert(member)
          }
      }
  }
  </code></pre>
  
  <p>It should work, if I return a tuple as expected but no idea how and where (which line) and what to return a value.</p>
  
  <p>Here is error message. </p>
  
  <blockquote>
    <p>Missing return in a function expected to return '(inserted: Bool, memberAfterInsert: Set.Element)'</p>
  </blockquote>
  
  <p><a href="https://i.stack.imgur.com/7pVOD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7pVOD.png" alt="enter image description here"></a></p>
  
  <p>What can be solution to this. Is there any better solution/approach to handle this operation?</p>