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 Declaring a Struct

what do you mean a stored property

in a quiz i saw stored property and i did not know what that meant

structs.swift
// Enter your code below
struct User{
let name = priyanka
let age = 5\0*9
{

1 Answer

Joshua C
Joshua C
51,696 Points

Straight from the Apple Documentation (https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Properties.html#//apple_ref/doc/uid/TP40014097-CH14-ID255) :

"A stored property is a constant or variable that is stored as part of an instance of a particular class or structure." For example, every time you create an instance of your User struct, that instance will include access to the 'stored properties,' "name," and "age" (which you've set to priyanka and 5\0*9).

Your code is probably giving you an error because the 'name' property must be string and the age property must be an int. You are not surrounding your name with double quotes (") and in your 'age' property, you are trying to divide by zero, which will definitely give you an error. Plus, you are using the wrong character for division which should be a forward slash (/) instead of a backslash (\).

Your answer should be something like this:

struct User{
   let name = "priyanka"
   let age = 5
{