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 Object-Oriented Swift Complex Data Structures Creating an Instance

I cannot solve the first object oriented code challenge

I entered this code but it will not compile, can someone help me?

structs.swift
struct Book {
  let title: String
  let author: String
  let price: Double
}
let myBook = Book(title:AnimalFarm, author:GeorgeOrwell, price: 6.00)

2 Answers

andren
andren
28,558 Points

Strings (arbitrary text) has to be wrapped in quotes, if you don't wrap them in quotes Swift will think you are trying to reference a variable or something along those lines. Additionally challenges are pretty strict about how strings look, when they ask you to pass in something like "Animal Farm" for title it needs to look exactly like that, spacing and all.

If you fix those issues like this:

struct Book {
  let title: String
  let author: String
  let price: Double
}
let myBook = Book(title: "Animal Farm", author: "George Orwell", price: 6.00)

Then your code will work.

hey I realized right after I posted I forgot those. thanks so much