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 Swift Basics (retired) Types Strings

Joseph F Fares Jr
Joseph F Fares Jr
517 Points

Print & 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:

  1. I noticed now an error comes up when try to use println. It is telling me to use just print.

  2. 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

Fred,

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

1 Answer

shane reichefeld
PLUS
shane reichefeld
Courses Plus Student 2,232 Points

In 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 }