# hashCode property

1. @override

int get hashCode
override

Returns the hash code of the value, if present, otherwise `0` (zero) if no value is present.

Returns hash code value of the present value or `0` if no value is present.

## Example

    Optional<String> name = Optional.of("Noah");
    Optional<String> empty = Optional.empty();

    print(name.hashCode); // Same as "Noah".hashCode
    print(empty.hashCode); // 0

    // Useful for using Optionals as map keys
    Map<Optional<String>, int> counts = {};
    counts[Optional.of("apple")] = 5;
    counts[Optional.empty()] = 0;

    print(counts[Optional.of("apple")]); // 5
    print(counts[Optional.empty()]); // 0

## Implementation

    @override
    int get hashCode {
      return _value?.hashCode ?? 0;
    }