Group Group Group Group Group Group Group Group Group

Programming in Swift: Functions and Types · Challenge: Overloads & Parameters | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5429279-programming-in-swift-functions-and-types/lessons/6

i keep on downloading the marials and it only gives me the intro ones

None of the materials have exercises for this course. They all say “exercises and challenges for Part 1 of the Programming in Swift: Functions and Types course,”

@brocket12 @codes Playground files can contain more than one page! There is one playground file for each part of this course, and one page in those playgrounds for each episode in the part.

To see all of the pages, open the Navigator just like you would to see all of the files in a regular Xcode project. You can open and close the Navigator with the keyboard shortcut Command 0, or use the button circled in the screenshot below.

Hey Catie,

Thanks for the quick reply! However, some of the exercises are already completed. For example, the Challenge for Overloads & Parameters was already filled out upon clicking on it

Hi! I just took a look and found a couple lines to remove (I’ll get the downloads updated shortly), but the meat of the challenges are not completed in the version you already have.

Make sure you’re working in the “Begin” playground. Also, a lot of the challenges in this course will have some code already in the playground for you to modify or use in some way. That’s the case for the Overloads & Parameters challenge!

Hi Catie,

You’re right! The majority of the exercises are there - sorry for the confusion. Please let me know once you’re able to push the updates. Much appreciated!

Ok, updates are up! :]

In Challenge 3: I didn’t understand the “withPoints points” thing.

Why did I have to use “withPoints” when calling the func? Which lesson covers this?

And by “right parameter” I think you mean “correct parameter”?

In Challenge 1: I don’t understand the “by” in the parameters. I tried to search for this, but the word is too generic and I don’t know what the concept is here.

Hi! In both of your questions, you’re asking about argument labels. Not all programming languages use argument labels, but Swift does!

You can learn about them in this episode of the Swift Fundamentals course: https://www.raywenderlich.com/5539282-programming-in-swift-fundamentals/lessons/35

I also reviewed them in the second episode of this course:
https://www.raywenderlich.com/5429279-programming-in-swift-functions-and-types/lessons/2

To sum it up here: Parameter names are how you refer to the parameter values inside the function body. When you call a function that has parameters, you pass in arguments. The parameter names turn into argument labels, unless you put an alternative in the parameter list right before the parameter. You can either say you don’t want an argument label with an _ or specify a different argument label.

Here’s a generic kind of code diagram of argument labels and parameter names:

func functionName(argumentLabel parameterName: ParameterType) { 
  // parameterName is used in here 
}

// argument label is used when you call the function
functionName(argumentLabel: argument) 

For your specific questions, both withPoints and by are argument labels! withPoints acts as the argument label for points, and by is the argument label for multiplier.

I’m not sure what you mean about “right parameter”. I couldn’t find where I said this in the video!

Thanks very much. I missed that.

By “right parameter”, I meant in the download materials. Part 6, Challenge 3, step 1.

1 Like

Oh! Apologies.
Yes, I did mean “correct parameter,” not “the parameter on the right side of the parameter list”.