Skip to content

Commit

Permalink
Update Change Reference to Value
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoMatilla committed Apr 2, 2020
1 parent bbffb81 commit b308660
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -920,15 +920,18 @@ _Turn it into a value object_
to
```java
// Add `equals` and `hashCode`
public boolean equals(Object arg) {
if (! (arg instanceof Currency)) return false;
Currency other = (Currency) arg;
return (_code.equals(other._code));
}
// Add `equals` and `hashCode` to the Currency class
class Currency{
...
public boolean equals(Object arg) {
if (! (arg instanceof Currency)) return false;
Currency other = (Currency) arg;
return (_code.equals(other._code));
}
public int hashCode() {
return _code.hashCode();
public int hashCode() {
return _code.hashCode();
}
}
// Now you can do
Expand Down

0 comments on commit b308660

Please sign in to comment.