Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
This is tricky.
new String
will never be interned if not interned explicitly, because it is, well,new
-ed. So it's always new in the beginning, you will not get an interned instance by callingnew
(it can be interned later, but details are not simple). But. C# has the concept of operator overloading (unlike Java), and it overloads theoperator ==
for many value types, including string. That's whystr1 == str2
performs value equality check, and not a reference equality check.new String("") == ""
will always returntrue
. But. The example you showed does not perform a string equality check. It compares anobject
with astring
, so the overloadedString.operator ==
does not kick in. The comparison is a reference equality check, and, in this case, it will returntrue
only when checking equality of interned string instances.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution