title: Swift generic constructor
body: <p><strong>The questions are embedded in comments</strong> as well as here:</p>
  
  <ol>
  <li>How can I define a default value for a generic T in parameter list? </li>
  <li>When copying a parameter in Swift, is it pointers or objects?
  <ul>
  <li>XCode Beta 7 tells me I can't change "head", as it is a "let", see code</li>
  </ul></li>
  <li>Any Swift-like way to while-loop checking for nil to avoid unwrapping?</li>
  </ol>
  
  <p>Linked List implementation:</p>
  
  <pre><code>public class Node&lt;T&gt;
  {
      public var data: T
      public var next: Node&lt;T&gt;?
  
      //1.
      //How can I define a default datatype for T?
      //In C++ I would let T ctor do it: "data: T = T()" gives 
      //error: 'T' cannot be constructed because it has no accessible initializers
      public init(data: T, next: Node&lt;T&gt;?)
      {
          self.data = data
          self.next = next
      }
  }
  
  func print&lt;T&gt;(head: Node&lt;T&gt;)
  {
      var tmp = head  //2. Is this a copy of a pointer or an object?
      print(tmp.data)
      while(tmp.next != nil)  //3. Any Swiftier way to do it?
      {
          tmp = tmp.next!
          print(tmp.data)
      }
  }
  
  func insert&lt;T&gt;(head: Node&lt;T&gt;, _ value: T)
  {
      var tmp = head
      while tmp.next != nil
      {
          tmp = tmp.next!
      }
      tmp.next = Node&lt;T&gt;(data: value, next: nil)
  }
  
  var head = Node&lt;Int&gt;(data: 1, next: nil)
  insert(head, 2)
  insert(head, 4)
  insert(head, 8)
  insert(head, 16)
  print(head)
  </code></pre>
  
  <p>Also, any other comments? I'm very new to Swift</p>