FAQ: Enumerations - Implementing a Computed Property in an Enumeration

This community-built FAQ covers the “Implementing a Computed Property in an Enumeration” exercise from the lesson “Enumerations”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Intermediate Swift

FAQs on the exercise Implementing a Computed Property in an Enumeration

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

The first task is this:

Create a computed variable property in Vehicle called description that returns a String value.
Here are the description values for each case:

  • Airplane returns: "This is an airplane"
  • Boat returns: "This is a boat"
  • Truck returns: "This is a truck" if isFourWheelDrive is false
  • Truck returns: "This is a truck with four wheel drive" if isFourWheelDrive is true

The problem:

The code is only accepted if it is an exact copy of the suggested solution. It didn’t matter that my code had the correct logic for returning the truck’s description based on if it’s four wheel drive or not. I had to check the solution and replace my code with the solution before it was accepted.

In other words, this was a task of “guess the exact way someone else did this”.

What is the exact same solution, I’m unable to get it correct. My solution should work but does not match what they are asking for.

enum Vehicle {
case airplane
case boat
case truck(isFourWheelDrive: Bool)

// 1: Create computed value here
var description : String {
  switch self {
    case .airplane:
      return "This is an airplane"
    case .boat:
      return "This is a boat"
    case .truck(let isFourWheelDrive):
      if isFourWheelDrive {
        return "This is a truck with four wheel drive"
      } else {
        return "This is a truck"


I found a bug in View Solution mode. There are two the same parts of code, but one of them is not my code. I didn’t use ternary operator, so algorithm has taken the solution code and put it to both sections: my code and solution.