R

Ravina • 2.56K Points
Extraordinary

Q. Which of the following is a correct way to define an enum in Swift?

  • (A) enum Color { red, green, blue }
  • (B) enum Color = [red, green, blue]
  • (C) enum Color: [String] = ["red", "green"]
  • (D) enum Color: String { case red, green, blue }
  • Correct Answer - Option(D)
  • Views: 1
  • Filed under category Swift (iOs)
  • Hashtags:

Explanation by: Ravina
This is the correct syntax for a Swift enum with raw values of type String.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.