Learn to Code via Tutorials on Repl.it!

← Back to all posts
Learn Swift 1
[deleted]

Hi! Today we will learn Swift.

Commands

Commands are simple. They look like this:
print(“Hello World!”)
As you can see, these commands don’t have a semicolon, unlike JavaScript and a few other languages.
Output:
Hello World!

Variables

It looks like this:
var name = 3
Output:
name = 3
Again, it doesn’t have a semicolon.
Variables can be changed, like this:
Add:
name += 1
Output:
name = 4
Subtract:
name -= 1
Output:
name = 2

Constants

These are written like this:
let name = 3
Output:
name = 3
You can not change these, so name will always be equal to 3.

Loops

Loops are written like this:

This loop does nothing, but to make it do something, add code inside the curly brackets.

That’s it for today!

Voters
elbryant
arcalia
SabirMyrzaev
Pcat1
M1Sanz
justlearninglol
kostrowski72
Chilton7771
RaahaKumaresan
StefanSimon2
Comments
hotnewtop
DJWang

Cool

GNVAGEESH

thank you

Psianturi

Nice

[deleted]

Why aren’t the code blocks working?

theangryepicbanana

@CodeABC123 try using `

[deleted]

I tried that already!!! @theangryepicbanana

[deleted]

Never mind. @CodeABC123

theangryepicbanana

@CodeABC123 you used a different character. you should be using backticks, not single quotes

[deleted]

Not letting me edit. @theangryepicbanana

theangryepicbanana

@CodeABC123 I think you have to verify your email in order to edit your posts

[deleted]

Ugh, I’ll just make a new post and delete this post. @theangryepicbanana

[deleted]

Nothing is WORKING!!! @CodeABC123

theangryepicbanana
[deleted]

Just a small, or more like a HUGE problem: I can’t post anything anymore. @theangryepicbanana

[deleted]

I can only post comments. And I’m about to delete this post. @CodeABC123

[deleted]

Can’t delete. @CodeABC123

[deleted]

Do you think people will still understand the post? @theangryepicbanana

theangryepicbanana

@CodeABC123 probably

[deleted]

I can post again! @CodeABC123

[deleted]

I have finally verified my email! @theangryepicbanana

theangryepicbanana

@CodeABC123 nice 👍