Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJoshua De La Rosa
2,721 PointsHaving trouble no matter what i try i can't assign the return value to result. IN Task 2
in task 2 of the quiz it asks me to create a variable result and assign the return value to result. Ive tried a lot and it tells me same thing you need to assign return value greeting to result.
Can some one please teach me the code to do this
func greeting(person: String, language: String) -> (greeting: String, language: String) {
let language = "English"
let greeting = "Hello \(person)"
return (greeting, language)
}
let result = greeting
1 Answer
Chris Shaw
26,676 PointsHi Joshua,
The question for task 2 is as follows:
Create a variable named
result
and assign it the tuple returned from functiongreeting
. (Note: pass the string"Tom"
to thegreeting
function.)
What this means is we need to create a variable called result
and assign is the return value of greeting
which means we need to call this function and pass it the argument Tom as the parameter.
var result = greeting("Tom")
Happy coding!
Joshua De La Rosa
2,721 PointsJoshua De La Rosa
2,721 Pointsthank you very much i feel dumb now and can now see what i was doing wrong
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsNo worries, also this has happened to a number of other students too, it's just the process of learning
Phil Hanson
764 PointsPhil Hanson
764 PointsThis is still currently failing in Treehouse editor.
Gets the error
Bummer! You need assign the return value of the 'greeting' function to 'result'