Posts

Post not yet marked as solved
4 Replies
7.9k Views
in the playground 9.1 im learning Xcode. at lesson 10, i can't understand argument label and parameter name.could please explain them to me VERY easily.for example i didn't understand the Exercise: argument label below:what should i do now?thank you.../: ## Exercise: Argument Label Functions and their arguments should be named so that they read like a clear instruction when they’re called. To make this easier, you can give parameters two names - an _argument label_ to be used when calling the function and a _parameter name_ to be used within the function’s body. */ func score(reds: Int, greens: Int, golds: Int) -> Int { let pointsPerRed = 5 let pointsPerGreen = 10 let pointsPerGold = 30 let redScore = reds * pointsPerRed let greenScore = greens * pointsPerGreen let goldScore = golds * pointsPerGold return redScore + greenScore + goldScore } let finalScore = score(reds: 5, greens: 3, golds: 3) /: - callout(Exercise): Add an argument label to the function definition so it reads like this when you call it:\ `let finalScore = score(withReds: 5, greens: 3, golds: 3)` */ //: [Previous](@previous) | page 16 of 17 | [Next: Exercise: No Argument Label](@next)
Posted
by ommshi.
Last updated
.
Post marked as solved
11 Replies
2.6k Views
hi guysI really thought about This question, but I couldn't answer thatCould you please tell me what is the solution or how i can solve it?in Intro to App Development Curriculum lesson 14Exercise: Counting VotesYou're implementing a poll app for your class. You start with a basic yes-no question counter and now you have your first batch of answers back, parsed into arrays below.This is a lot of data! But don't worry too much about the long arrays. Whether you're planning to loop over two items or two thousand, you’ll write the loop in exactly the same way.let shouldMascotChangeVotes: [Bool] = [false, false, false, true, false, true, true] let shouldInstallCoffeeVendingMachineVotes: [Bool] = [true, true, false, false] let shouldHaveMorePollOptionsVotes: [Bool] = [false, false, true, true, false, true, false, false, false, false]This is too many votes to tally quickly by hand, so you’ll write some code to tally it for you.NOTEThis is also a lot of votes for Swift to use type inference to determine what kind of array it has. The type annotation is written in the array literals above to tell Swift the type of array. This prevents the playground from running slowly.
Posted
by ommshi.
Last updated
.