Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: lib/core/object.dart

Issue 10974004: Add documentation to the Object class in the core library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « lib/compiler/implementation/lib/core_patch.dart ('k') | runtime/lib/object_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Everything in Dart is an [Object]. 6 * Everything in Dart is an [Object].
7 */ 7 */
8 class Object { 8 class Object {
9 /**
10 * Creates a new [Object] instance.
11 *
12 * [Object] instances have no meaningful state, and are only useful
13 * through their identity. An [Object] instance is equal to itself
14 * only.
15 */
9 const Object(); 16 const Object();
10 17
18 /**
19 * The equality operator.
20 *
21 * The default behavior for all [Object]s is to return true if and
22 * only if [:this:] and [other] are the same object.
23 *
24 * If a subclass overrides the equality operator it should override
25 * the [hashCode] method as well to maintain consistency.
26 */
11 bool operator ==(other) => identical(this, other); 27 bool operator ==(other) => identical(this, other);
12 28
29 /**
30 * Get a hash code for this object.
31 *
32 * All objects have hash codes. Hash codes are guaranteed to be the
33 * same for objects that are equal when compared using the equality
34 * operator [:==:]. Other than that there are no guarantees about
35 * the hash codes. They will not be consistent between runs and
36 * there are no distribution guarantees.
37 *
38 * If a subclass overrides [hashCode] it should override the
39 * equality operator as well to maintain consistency.
40 */
13 external int hashCode(); 41 external int hashCode();
14 42
43 /**
44 * Returns a string representation of this object.
45 */
15 external String toString(); 46 external String toString();
16 47
17 external void noSuchMethod(String name, List args); 48 /**
49 * [noSuchMethod] is invoked when users invoke a non-existant method
50 * on an object. The name of the method and the arguments of the
51 * invocation are passed to [noSuchMethod]. If [noSuchMethod]
52 * returns a value, that value becomes the result of the original
53 * invocation.
54 *
55 * The default behavior of [noSuchMethod] is to throw a
56 * [noSuchMethodError].
57 */
58 external Dynamic noSuchMethod(String name, List args);
18 59
60 /**
61 * Returns a representation of the runtime type of the object.
62 */
19 external Type runtimeType(); 63 external Type runtimeType();
20 } 64 }
21 65
66 /**
67 * Representation of a type.
68 */
22 abstract class Type {} 69 abstract class Type {}
23 70
24 /** 71 /**
25 * Check whether two references are to the same object. 72 * Check whether two references are to the same object.
26 */ 73 */
27 bool identical(Object a, Object b) => a === b; 74 bool identical(Object a, Object b) => a === b;
OLDNEW
« no previous file with comments | « lib/compiler/implementation/lib/core_patch.dart ('k') | runtime/lib/object_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698