Where was the substance to the post? The post she linked to was far more interesting: https://netguru.co/blog/posts/brace-no-more-going-from-java-...
@Override
public boolean equals(Object object) {
if (!(object instanceof Gallery)) return false;
Gallery other = (Gallery) object;
return (this.gid != null || other.gid == null) && (this.gid == null || this.gid.equals(other.gid));
}
Apart from the cast, which you need because Java has static types and Ruby doesn't, it's the same length. It's basically the same code, token for token.Actually, the logical structure of the final line is a bit obscure to me; i'd write it:
return this.gid != null ? this.gid.equals(other.gid) : other.gid == null;
Or, in Java 7 or later: return Objects.equals(this.gid, other.gid);