Skip to content

Instantly share code, notes, and snippets.

@chinmaygarde
Created June 26, 2015 22:08
Show Gist options
  • Save chinmaygarde/b5ef23f9998665d37e9c to your computer and use it in GitHub Desktop.
Save chinmaygarde/b5ef23f9998665d37e9c to your computer and use it in GitHub Desktop.
HashCodeBuilder
class HashCodeBuilder {
int code = 1;
static const int hashPrime = 31;
HashCodeBuilder append(o) => this..code = (hashPrime * code) + o.hashCode;
}
void main() {
print((new HashCodeBuilder()).append(true).append(12.0).code);
print((new HashCodeBuilder()).append(true).append(12.0).code);
print((new HashCodeBuilder()).append(12.0).append(true).code);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment