Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Swift Enums and Structs Enums Associated Values

Paul Denlinger
Paul Denlinger
2,380 Points

Still getting incorrect answer

My answer is:

var book = Booktype.Pdf("Game of Thrones")

But it is still getting marked as the wrong answer. What is wrong?

enum.swift
enum BookType {
    // Write your members with associated values here
  case Pdf(String)
  case Epub(String)

}

var book = Booktype.Pdf("Game of Thrones")

2 Answers

Jiri Stepanek
Jiri Stepanek
10,740 Points

You have to do it like this: var book: Booktype = .Pdf("Game of Thrones")

When you initialized the instance "book", you didn't write "BookType" The ONLY THING you need to change is the "t"; make it a "T" because that is how it was written in the enum declaration of BookType.

var book = BookType.Pdf("Game of Thrones")