Dart num hashCode
Syntax & Examples
num.hashCode property
The `hashCode` property in Dart returns a hash code for a numerical value.
Syntax of num.hashCode
The syntax of num.hashCode property is:
 int hashCode This hashCode property of num returns a hash code for a numerical value.
Return Type
num.hashCode returns value of type  int.
✐ Examples
1 Hash code of an integer
In this example,
- We create a num variable numberwith the value 42.
- We access its hash code using the hashCodeproperty.
- We then print the hash code to standard output.
Dart Program
void main() {
  num number = 42;
  int hash = number.hashCode;
  print('Hash code of $number: $hash');
}Output
Hash code of 42: 42
2 Hash code of a double
In this example,
- We create a num variable numberwith the value 3.14.
- We access its hash code using the hashCodeproperty.
- We then print the hash code to standard output.
Dart Program
void main() {
  num number = 3.14;
  int hash = number.hashCode;
  print('Hash code of $number: $hash');
}Output
Hash code of 3.14: 468150022
3 Hash code of a negative integer
In this example,
- We create a num variable numberwith the value -10.
- We access its hash code using the hashCodeproperty.
- We then print the hash code to standard output.
Dart Program
void main() {
  num number = -10;
  int hash = number.hashCode;
  print('Hash code of $number: $hash');
}Output
Hash code of -10: 536870902
Summary
In this Dart tutorial, we learned about hashCode property of num: the syntax and few working examples with output and detailed explanation for each example.
