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 trialEdward Cohen
1,152 PointsWhat is the difference between printing a value and returning a value in a function
Functions
1 Answer
Gunhoo Yoon
5,027 PointsYou cannot re-use printed value but you can re-use returned value. You can think printing as sending data to screen and returning as sending data outside of function within program.
You should test this by yourself since I'm not familiar with swift.
Prepare two functions, one that prints and another that returns. Save both result as separate variable and try to print out those variable or re-use it somehow.
NOUR A ALGHAMDI
Courses Plus Student 5,607 PointsNOUR A ALGHAMDI
Courses Plus Student 5,607 Pointsi tried to do this but no clear result , :(
Gunhoo Yoon
5,027 PointsGunhoo Yoon
5,027 PointsSorry I don't have knowledge in Swift but in general, programming languages agree on what print and return do.
So consider this.