Skip to content

Commit

Permalink
Add GetHashCode overrides to variable types to suppress warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Feb 3, 2022
1 parent a14260c commit 0527380
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions EOBot/Interpreter/Variables/BoolVariable.cs
Expand Up @@ -12,6 +12,8 @@ public class BoolVariable : IVariable<bool>

public override bool Equals(object obj) => CompareTo(obj) == 0;

public override int GetHashCode() => Value.GetHashCode();

public int CompareTo(object obj) => obj is BoolVariable ? Value.CompareTo(((BoolVariable)obj).Value) : -1;

public static explicit operator bool(BoolVariable input) => input.Value;
Expand Down
2 changes: 2 additions & 0 deletions EOBot/Interpreter/Variables/IntVariable.cs
Expand Up @@ -12,6 +12,8 @@ public class IntVariable : IVariable<int>

public override bool Equals(object obj) => CompareTo(obj) == 0;

public override int GetHashCode() => Value.GetHashCode();

public int CompareTo(object obj) => obj is IntVariable ? Value.CompareTo(((IntVariable)obj).Value) : -1;

public static explicit operator int(IntVariable input) => input.Value;
Expand Down
2 changes: 2 additions & 0 deletions EOBot/Interpreter/Variables/StringVariable.cs
Expand Up @@ -12,6 +12,8 @@ public class StringVariable : IVariable<string>

public override bool Equals(object obj) => CompareTo(obj) == 0;

public override int GetHashCode() => Value.GetHashCode();

public int CompareTo(object obj) => obj is StringVariable ? Value.CompareTo(((StringVariable)obj).Value) : -1;

public static explicit operator string(StringVariable variable) => variable.Value;
Expand Down

0 comments on commit 0527380

Please sign in to comment.