Skip to content

Commit fd41fe7

Browse files
committed
Symbol: fixed equality test.
1 parent 1161c83 commit fd41fe7

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

Naggum.Runtime/Symbol.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,36 @@ public Symbol(String aName)
1616

1717
bool IEquatable<Symbol>.Equals(Symbol other)
1818
{
19-
return Name.Equals(other.Name);
19+
return AreEqual(this, other);
2020
}
2121

22+
public override bool Equals(object obj)
23+
{
24+
var symbol = obj as Symbol;
25+
if (symbol != null)
26+
{
27+
return AreEqual(this, symbol);
28+
}
29+
30+
return false;
31+
}
32+
33+
public override int GetHashCode()
34+
{
35+
return Name.GetHashCode();
36+
}
37+
2238
/// <summary>
2339
/// </summary>
2440
/// <returns>Returns symbol's name as string.</returns>
2541
public override string ToString()
2642
{
2743
return Name;
2844
}
45+
46+
private static bool AreEqual(Symbol one, Symbol other)
47+
{
48+
return one.Name.Equals(other.Name);
49+
}
2950
}
3051
}

0 commit comments

Comments
 (0)