Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,538 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.