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 trialIngrid Stevens
1,651 PointsYou 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
1 Answer
Marlon Henry
6,885 PointsBased on your message example you would actually do var welcomeMessage: String() the whole explicit type thing and all.
Ezekiel Elin
3,839 PointsEzekiel Elin
3,839 PointsTechnically 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.