Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
{