In Swift 3 sometimes the underscore is there and sometimes it’s not. A bit like Schrodingers cat…(sorry, bad science joke)

So what doe it do exactly?

Well, let’s back track a little bit and talk about functions first. Any function that has some parameters passed into it MUST have those parameters names specified when the function is called.

Example Case 1:

Now sometimes the Swift 3 Underscore appears like this:

Can you spot the difference?

In the first one you had to specify “name: ” but in the second you didn’t have to, just like the good ol days of programming (or like C#).

Example Case 2:

Sometimes you have a variable that you declared but didn’t actually use. Underscore _ is a way of designing that variable and saving a teeny tiny bit of memory (for iPhone 4s users, clearly).

And those are the 2 basic cases of the underscore (at least that I remember off hand). Seen any others? Maybe you should post below and let me know!

Where to go Next

This tutorial comes straight out of The Complete iOS Developer Course. Over 40 hours long it contains everything you need to create awe inspiring apps fast!

Click here to check it out!

What Does the Swift 3 Underscore Mean?

Leave a Reply

Your email address will not be published. Required fields are marked *

Share This

Want this Post in Easy to Understand Video Form?

Then get theĀ Complete iOS Developer Course. Over 50 hours of pure Swift coding goodness designed to turn you into a coding master!

One Time Offer - $9! Click to Get it!



WARNING: Once this box is closed the offer will not be shown again.

Thank you!