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!
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
Whats the difference between returning a tuple and array
I cant get the difference between returning a tuple and an array. In both cases i return multiple values. And if i want to use the key value thing i can just use any collection like a dictionary. so Whats its edge ?
Eric Gu3,871 Points
With tuples, you have the ability to return a collection type consisting of different data types.
With arrays, all the items in the collection type must be of the same data type.
Akilah Jones18,397 Points
Also using tuples is more efficient...
(value1, value2, value3) = functionThatReturnsTuple
value = functionThatReturnsArray
value1 = value;
value2 = value;
value3 = value;