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) Types Printing Results

Kami Wang
Kami Wang
5,643 Points

I can't get the print text in the console. And when I print some variables, there is \n beside my string. What can I do?

let sex = "female"
"female"

print(sex)
"female\n"

1 Answer

Martin Wildfeuer
PLUS
Martin Wildfeuer
Courses Plus Student 11,071 Points

This is expected behavior. print automatically appends a line break a the end, that is \n. If you run the code above in Xcode, you won't see the \n, it is interpreted as a line break there. This is really for convenience, as otherwise all print statements would just end up in one line. You can explicitly prevent the line break with:

print(sex, separator: "", terminator: "")

Hope that helps :)

Kami Wang
Kami Wang
5,643 Points

Cool. But why can't I see anything in my assistant editor?

Ryan Brege
Ryan Brege
Courses Plus Student 1,909 Points

Just like Kami, I am also seeing nothing in my Assistant Editor.

One of the biggest problems with online learning, in my eyes, is the differences in program iterations as new versions and updates are released. It is my opinion that, to stay competitive, it is in the instructors' best interest to find a way to append the current courses with footnotes (or perhaps a new video entirely) each time a program we are using is refurbished.

Then, in the future, they can remove or edit information as it relates to future releases.

Nonetheless, it is incredibly frustrating when you're trying to learn something for the first time and you're running into obstacles with these courses that are simply a matter of outdated information.

It makes us think we're doing something wrong, and that's utterly counterproductive to our learning process.

:(

Martin Wildfeuer
Martin Wildfeuer
Courses Plus Student 11,071 Points

Agreed. This especially true for Swift, which is a brand new and constantly evolving language. Language features are introduced and deprecated with every single iteration, unlike most (all?) of the other programming languages taught here. Therefore, I have to say that I do understand that it's very hard for the Treehouse staff to keep up with these constant changes.

Having said that, the teachers notes should indeed mention when things in videos have changed or are not valid anymore. I have seen that on some of those already. Also, the online assistant editor is not really helpful many times, although I always write my code in Xcode Playgrounds to benefit from autocompletion and warnings and I encourage every student to do that. I do understand, though, that this is not possible from iPads.

My suggestion is to address these things by mentioning the teachers in the comments, or contact Treehouse via support email directly. They are very helpful and keen on improving the experience for everyone.

Cheers :) Martin