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 2.0 Complex Data Structures Creating an Instance

Object-OrientedSwift. 2.0

Object-OrientedSwift 2.0

Challenge Task 1 of 1 Struct definitions are simply blueprints and to use them we need to create an instance. I've declared a struct in the editor. 
Create an instance of the struct and assign the values "Animal Farm", "George Orwell" and 6.00 to the title, author and price properties respectively. 
Assign this instance to a constant named myBook.

I'm lost in this help me

structs.swift
struct Book {
    let title: String
    let author: String
    let price: Double
}

let myBook = AnimalFarm = 6.00
let myBook = GeorgeOrwell = 6.00

2 Answers

Hi there,

Try creating the struct as if the initializer existed in code. That would force you to list each property in turn and assign a value to it.

Something like:

let myBook = Book(title: "Animal Farm", author: "George Orwell", price: 6.00)

Hope that helps.

Steve.

Thanks

No problem! :-)