title: What is the Swift equivalent of -[NSObject description]?
body: <p>In Objective-C, one can add a <code>description</code> method to their class to aid in debugging:</p>
  
  <pre><code>@implementation MyClass
  - (NSString *)description
  {
      return [NSString stringWithFormat:@"&lt;%@: %p, foo = %@&gt;", [self class], foo _foo];
  }
  @end
  </code></pre>
  
  <p>Then in the debugger, you can do:</p>
  
  <pre><code>po fooClass
  &lt;MyClass: 0x12938004, foo = "bar"&gt;
  </code></pre>
  
  <p>What is the equivalent in Swift? Swift's REPL output can be helpful:</p>
  
  <pre><code>  1&gt; class MyClass { let foo = 42 }
    2&gt; 
    3&gt; let x = MyClass()
  x: MyClass = {
    foo = 42
  }
  </code></pre>
  
  <p>But I'd like to override this behavior for printing to the console:</p>
  
  <pre><code>  4&gt; println("x = \(x)")
  x = C11lldb_expr_07MyClass (has 1 child)
  </code></pre>
  
  <p>Is there a way to clean up this <code>println</code> output? I've seen the <code>Printable</code> protocol:</p>
  
  <pre><code>/// This protocol should be adopted by types that wish to customize their
  /// textual representation.  This textual representation is used when objects
  /// are written to an `OutputStream`.
  protocol Printable {
      var description: String { get }
  }
  </code></pre>
  
  <p>I figured this would automatically be "seen" by <code>println</code> but it does not appear to be the case:</p>
  
  <pre><code>  1&gt; class MyClass: Printable {
    2.     let foo = 42
    3.     var description: String { get { return "MyClass, foo = \(foo)" } }
    4. }   
    5&gt; 
    6&gt; let x = MyClass()
  x: MyClass = {
    foo = 42
  }
    7&gt; println("x = \(x)")
  x = C11lldb_expr_07MyClass (has 1 child)
  </code></pre>
  
  <p>And instead I have to explicitly call description:</p>
  
  <pre><code> 8&gt; println("x = \(x.description)")
  x = MyClass, foo = 42
  </code></pre>
  
  <p>Is there a better way?</p>