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 trialokilydokily
12,105 PointsThis video was really confusing because you don't explain what a key is.
What is this "Key"? It looks like TKey is the same as when we used a dictionary. But why would Keys have anything to do with this because we aren't using a dictionary we are using lists and objects? Lists don't even have named items we could call a key.
2 Answers
Steven Parker
231,198 PointsThe "key" here isn't part of a data structure, but the field to be used in the "Join" operation to match with a similar field in the other data source.
okilydokily
12,105 PointsCan you explicate a little? What field? Fields are part of objects. I don't know if the items of a list are fields though. And as far as I can tell we are matching on values rather than variables. And what does this lambda have to do with a key/field?
Steven Parker
231,198 PointsSee the comment I added to my answer.
Steven Parker
231,198 PointsSteven Parker
231,198 PointsThe items of a list are not fields, but if the list contains objects, then fields are part of those objects. In this case, the "birds" list contains objects, and each object contains a "Color" field. That's the first (or "outer") key.
Then "colors" is just a list of strings, so the item itself ("
c -> c
") is used as the second ("inner") key.In both cases, the lambda returns the value to be used as the key when given the associated list item. This is needed because the "Join" arguments must be functions that return values and not the values themselves.