TOP(About this memo)) > 一覧(Dart) > オブジェクト
Dart is an object-oriented language with classes and mixin-based inheritance.
The base class for all Dart objects except null.
Dart is a true object-oriented language, so even functions are objects and have a type, Function.
var p1 = Point(2, 2);
var p1 = new Point(2, 2);
expect(identical(Object(), Object()), false);
- If x or y is null, return true if both are null, and false if only one is null.
- Return the result of invoking the == method on x with the argument y. (That’s right, operators such as == are methods that are invoked on their first operand. For details, see Operators.)
void main() {
print(Person == Person); // true
print(Person == Taro); // false
final taro = Taro();
print(taro.runtimeType == Taro); // true
final Person p1 = Taro();
print(p1.runtimeType == Person); // false
print((p1 as Person).runtimeType == Person); // false
// オブジェクトではないためisでの比較はfalseとなる
print(p1.runtimeType is Taro); // false
print(p1.runtimeType is Person); // false
print(taro is Taro); // true。常に真のため警告が表示される
print(taro is Object); // true。常に真のため警告が表示される
print(taro is Person); // true。常に真のため警告が表示される
print(10 is Object); // true。常に真のため警告が表示される
print(null is Object); // false(Dart 2.12 より前は false)
}
class Person{}
class Taro extends Person{}