Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. Object
  4. operator == method
operator ==
description

operator == method

booloperator ==(
  1. Objectother
)

The equality operator.

The default behavior for allObjects is to return true if andonly if this object andother are the same object.

Override this method to specify a different equality relation ona class. The overriding method must still be an equivalence relation.That is, it must be:

  • Total: It must return a boolean for all arguments. It should never throw.

  • Reflexive: For all objectso,o == o must be true.

  • Symmetric: For all objectso1 ando2,o1 == o2 ando2 == o1 musteither both be true, or both be false.

  • Transitive: For all objectso1,o2, ando3, ifo1 == o2 ando2 == o3 are true, theno1 == o3 must be true.

The method should also be consistent over time,so whether two objects are equal should only changeif at least one of the objects was modified.

If a subclass overrides the equality operator, it should overridethehashCode method as well to maintain consistency.

Implementation

external bool operator ==(Object other);
  1. Dart
  2. dart:core
  3. Object
  4. operator == method
Object class

[8]ページ先頭

©2009-2025 Movatter.jp