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
Trevor Wood
17,828 PointsWhat is <T> or type T in swift?
https://teamtreehouse.com/library/closures-in-swift-2/building-standard-library-functions/map
Pasan has some code here that mentions <T> and has a return type of T. But I'm not sure what this is exactly.
1 Answer
David Lin
35,864 PointsT is just a generic placeholder to represent any Type.
You can actually use any letter or word, but T is used by convention.
The most commonly used generic type parameter names are:
E - Element
K - Key
N - Number
T - Type
V - Value
S,U,V etc. - 2nd, 3rd, 4th types
Trevor Wood
17,828 PointsTrevor Wood
17,828 PointsAhhh I see, thank you so much!
David Lin
35,864 PointsDavid Lin
35,864 PointsYou're welcome! :-)