OLD | NEW |
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 part of dart.core; | 5 part of dart.core; |
6 | 6 |
7 /** | 7 /** |
8 * An [Expando] allows adding new properties to objects. | 8 * An [Expando] allows adding new properties to objects. |
9 */ | 9 */ |
10 class Expando<T> { | 10 class Expando<T> { |
11 | 11 |
12 /** | 12 /** |
13 * The name of the this [Expando] as passed to the constructor. If | 13 * The name of the this [Expando] as passed to the constructor. If |
14 * no name was passed to the constructor, the name is [null]. | 14 * no name was passed to the constructor, the name is [:null:]. |
15 */ | 15 */ |
16 final String name; | 16 final String name; |
17 | 17 |
18 /** | 18 /** |
19 * Creates a new [Expando]. The optional name is only used for | 19 * Creates a new [Expando]. The optional name is only used for |
20 * debugging purposes and creating two different [Expando]s with the | 20 * debugging purposes and creating two different [Expando]s with the |
21 * same name yields two [Expando]s that work on different properties | 21 * same name yields two [Expando]s that work on different properties |
22 * of the objects they are used on. | 22 * of the objects they are used on. |
23 */ | 23 */ |
24 external Expando([String name]); | 24 external Expando([String name]); |
25 | 25 |
26 /** | 26 /** |
27 * Expando toString method override. | 27 * Expando toString method override. |
28 */ | 28 */ |
29 String toString() => "Expando:$name"; | 29 String toString() => "Expando:$name"; |
30 | 30 |
31 /** | 31 /** |
32 * Gets the value of this [Expando]'s property on the given | 32 * Gets the value of this [Expando]'s property on the given |
33 * object. If the object hasn't been expanded, the method returns | 33 * object. If the object hasn't been expanded, the method returns |
34 * [null]. | 34 * [:null:]. |
35 */ | 35 */ |
36 external T operator [](Object object); | 36 external T operator [](Object object); |
37 | 37 |
38 /** | 38 /** |
39 * Sets the value of this [Expando]'s property on the given | 39 * Sets the value of this [Expando]'s property on the given |
40 * object. Properties can effectively be removed again by setting | 40 * object. Properties can effectively be removed again by setting |
41 * their value to null. | 41 * their value to null. |
42 */ | 42 */ |
43 external void operator []=(Object object, T value); | 43 external void operator []=(Object object, T value); |
44 | 44 |
45 } | 45 } |
OLD | NEW |