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

Java

Damion Keddie
Damion Keddie
5,036 Points

Where does C# go?

Hey all, time for a first question, though it's not really programming related. At the 6 minute mark in the video 'Sets', the language C# is added to the uniqueLanguages set, but at about 6.45 when we are being shown sorted sets, it has disappeared! Ghosts or an editing snafu?

2 Answers

andren
andren
28,558 Points

In this line:

SortedSet<String> uniqueLanguages = new TreeSet<String>(allLanguages)

The uniqueList variable is assigned to a new TreeSet, meaning that they replaced the current Set that existed within the variable with the new SortedSet. Since the allLanguages list is passed in during its creating the list ends up not empty even though it was recreated, but it will only contain the items in the allLanguages list, the items assigned to it previously will disappear since the variable was reassigned to a completely new TreeSet.

So to answer your question it's neither a dodgy edit or a bug.

Damion Keddie
Damion Keddie
5,036 Points

Good catch, never considered that.