You can use pattern matching to match and extract the values associated with an enumeration case such as Status.Delayed(Int)
. The extension below extends the Train
class to conform to Swift’s Printable
protocol, which requires a conforming type to provide a readable string description
property. This extension makes it easy to retrieve a String
value that includes the number of minutes that the train is delayed.