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 trialJoseph F Fares Jr
517 PointsPrint & Creating a List Question
The following is my code:
print("List: \n 1 \t Apple \n 2 \t Bananas \n 3 \t Oranges")
Results: The list is created
Problems:
I noticed now an error comes up when try to use println. It is telling me to use just print.
The list is not lined up in the left hand side.
What changed: I read on Google that Swift 2.0 just uses print() and not println() - not sure if this is correct. Also I did upgrade xcode to 7.2
Thank you for your help Fred
1 Answer
shane reichefeld
Courses Plus Student 2,232 PointsIn swift 2.0 the print statement is just print() not println(). For the alignement problem you can just use concatenation or set var or constants then wrote code or use a while loop.
let list = ["apple", "fruit", "candy"] let i = 0 while (i < list) { print(list[i]) ++i }
Josh Bibbs
16,092 PointsJosh Bibbs
16,092 PointsFred,
Starting in Swift 2.0, the print function changed to just "print" as opposed to "println". You can find a little more info on this at the link below.
http://stackoverflow.com/questions/25951195/swift-print-vs-println-vs-nslog
Josh