Super basic question: Print

Hello community,

This is my first post here. It's a super basic question. I'm starting to learn Swift and I'm using a Swift Playground from Xcode.

I have tried to print a text like this:

print("Hello, world")

However the output is adding a "\n" symbol, resulting in:

"Hello, world\n"

Any thoughts?

Thanks in advance, Rodrigo

Answered by Claude31 in 758635022

Welcome to the forum.

You get :

"Hello, world\n"

on the right part of the screen.

If you look in the console at the bottom, you just see:

Hello, world

The reason is that, for the next print, the linefeed (\n) was automatically added to present new print on a newline.

So, it is normal behavior, nothing to change or worry about.

Accepted Answer

Welcome to the forum.

You get :

"Hello, world\n"

on the right part of the screen.

If you look in the console at the bottom, you just see:

Hello, world

The reason is that, for the next print, the linefeed (\n) was automatically added to present new print on a newline.

So, it is normal behavior, nothing to change or worry about.

Hello @Claude31,

Thanks for welcoming me!

Thank you very much for the clarification. I totally see that now, your explanation was very thorough and clear.

Have a great day! R.

Super basic question: Print
 
 
Q