title: What is the difference between passing classes as generic types or types?
body: <p>In the Swift documentation, I came across a section which was saying that I can write type constraints like a method or a protocol. However, what I didn't understand were the benefits of writing this way. Why don't simply pass the class (or protocol) itself?</p>
  <p>Documentation: <a href="https://docs.swift.org/swift-book/LanguageGuide/Generics.html" rel="nofollow noreferrer">https://docs.swift.org/swift-book/LanguageGuide/Generics.html</a></p>
  <p>Let me explain with an example.</p>
  <pre><code>import Foundation
  
  class A {
      init(val: String) {
          self.val = val
      }
      let val: String
  }
  
  func someFunction&lt;T: A&gt;(someT: T) {
      print(someT.val)
  }
  
  func someFunction2(someT: A) {
      print(someT.val)
  }
  
  // method 1
  someFunction(someT: A(val: &quot;asdasd&quot;))
  // method 2
  someFunction2(someT: A(val: &quot;asdasd&quot;))
  </code></pre>
  <p>In the snippet below, what is the difference between method 1 and method 2?</p>