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 trial

iOS Functions in Swift Adding Power to Functions Default Values

Paul Karim
Paul Karim
3,428 Points

Wouldn't it be easier to simply call the area function as the area argument?

Hey Guys!

Quick question, so in the last video Pasan chose to change the carpetCost func to accept length and width arguments to then call the area func inside the carpetCost func. I was just thinking wouldn't have been easier to just call the area func AS the area argument?

Ex. carpetCost(havingArea: area(length: 20, width: 22), carpetColor: "tan")

Love to hear input on this matter, thanks!

1 Answer

Paul, I see no reason why this would not work. Definitely give it a try! Pasan teaches in a very fathomable way, but with any type of programming, there are always at least two or three ways to complete a task. Sometimes being creative leads to a better solution in the end. Although I am not giving you a direct answer, I hope this idea will help you somewhat Paul!

If you have any further questions, don't hesitate to ask!