Textual Representation for Classes (Swift)

Swift make it easy to convert a custom class to a string (e.g. for use with print) via the CustomStringConvertible protocol. (a clear improvement over earlier implementations)

class X : CustomStringConvertibleĀ  {
  var description: String{
    return "This is class X"
  }
}

print(X()) //output is: "This is class X"