The function we created earlier returns an optional value, so if we want to do anything useful with the resulting value, we need to unwrap the optional. So far, the only way we have seen how to do this is by force unwrapping, which will cause a crash if the value is nil.
Instead, we can use an if statement to conditionally unwrap the optional, turning it into a more useful, non-optional value.
Let's create a function that will print information about a pool ball of a given number. If the provided number is valid for a pool ball, it will print the ball's number and type; otherwise, it will print a message explaining that it is not a valid number.
Since we will want to print the value of the PoolBallType enum, let's make it String backed, which will make printing its value easier:
enum PoolBallType: String {
case solid
case stripe
case black
}
Now, let's write the function to print the pool ball details:
func printBallDetails...