Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. identityHashCode function
identityHashCode
description

identityHashCode function

intidentityHashCode(
  1. Object?object
)

The identity hash code ofobject.

Returns the value that the originalObject.hashCode would returnon this object, even ifhashCode has been overridden.

This hash code is compatible withidentical,which means that it's guaranteed to give the same result every timeit's passed the same argument, throughout a single program execution,for anynon-record object.

The identity hash code of aRecord is undefined,because a record doesn't have a guranteed persistent identity.A record values identity and identity hash code can change at any time.

var identitySet = HashSet(equals: identical, hashCode: identityHashCode);var dt1 = DateTime.now();var dt2 = DateTime.fromMicrosecondsSinceEpoch(dt1.microsecondsSinceEpoch);assert(dt1 == dt2);identitySet.add(dt1);print(identitySet.contains(dt1)); // trueprint(identitySet.contains(dt2)); // false

Implementation

@pragma("vm:entry-point")external int identityHashCode(Object? object);
  1. Dart
  2. dart:core
  3. identityHashCode function
dart:core library

[8]ページ先頭

©2009-2025 Movatter.jp