title: Satisfying ExpressibleByArrayLiteral Protocol
body: <p>Why when I extend the ExpressibleByArrayLiteral protocol in swift I need to make the init required. In the definition of the protocol, the init method is just public. </p>
  
  <p>I pretty much have the same thing as in the doc, <a href="https://developer.apple.com/reference/swift/expressiblebyarrayliteral" rel="nofollow noreferrer">https://developer.apple.com/reference/swift/expressiblebyarrayliteral</a>, and still, the compiler complains about making this <code>init(arrayLiteral: Element...)</code> required. The only difference I have is that I am implementing it in a class no a struct. Any suggestions?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Here is an implementation of my code:</p>
  
  <pre><code>public class Stack&lt;T&gt; {
  private var buffer: [T]
  
  init() {
      self.buffer = []
  }
  
  public func push(_ value: T) {
      self.buffer.append(value)
  } 
  
  public func pop() -&gt; T? {
      return self.buffer.popLast()
  }
  
  var size: Int {
      return self.buffer.count
  }
  
  var isEmpty: Bool {
      return self.size == 0
  }
  } 
  
  extension Stack: ExpressibleByArrayLiteral {
      init(arrayLiteral: T...) {
          for item in arrayLiteral {
              self.push(item)
          }
      }
  }
  </code></pre>
  
  <p>The errors I am getting are:</p>
  
  <p>1) designated initializer cannot be declared in an extension of 'Stack'; did you mean this to be a convenience initializer?</p>
  
  <p>2) initializer 'init(arrayLiteral:)' must be declared public because it matches a requirement in public protocol 'ExpressibleByArrayLiteral'</p>
  
  <p>3) initializer requirement 'init(arrayLiteral:)' can only be satisfied by a <code>required</code> initializer in the definition of non-final class 'Stack'</p>
  
  <p><strong>Questions</strong>:</p>
  
  <p><strong>For error #1 -></strong> Why can't I declare a designated init in an extension?</p>
  
  <p><strong>For error #2 -></strong> I understand this part, the protocol defines this as public. But why does the docs implement it with out the public keyword?</p>
  
  <p><strong>For error #3 -></strong> This is pretty much my biggest question, why this needs to be required.</p>
  
  <p>Thank you for your help!</p>