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 Basics (retired) Operators Unary Operators

You can initialize a variable without giving it a value

In the video at 00:54 you said "Because we can't just create a variable and not provide it with an initial value, because it needs to know whether it's an integer or a double or a float or a Boolean."

You can initialize a variable in swift without giving it a value because you can specify the type. For example:

var welcomeMessage: String var red, green, blue: Double

See documentation: https://developer.apple.com/library/mac/documentation/swift/conceptual/swift_programming_language/TheBasics.html#//apple_ref/doc/uid/TP40014097-CH5-XID_467

Technically true, however if you don't specify the types, you must provide the value. At this point in the course I don't believe types have been touched on much.

1 Answer

Based on your message example you would actually do var welcomeMessage: String() the whole explicit type thing and all.