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 /** | 5 /** |
6 * | 6 * |
7 * Built-in types, collections, | 7 * Built-in types, collections, |
8 * and other core functionality for every Dart program. | 8 * and other core functionality for every Dart program. |
9 * | 9 * |
10 * This library is automatically imported. | 10 * This library is automatically imported. |
(...skipping 21 matching lines...) Expand all Loading... |
32 * | 32 * |
33 * A [String] is immutable and represents a sequence of characters. | 33 * A [String] is immutable and represents a sequence of characters. |
34 * | 34 * |
35 * String shakespeareQuote = "All the world's a stage, ..."; | 35 * String shakespeareQuote = "All the world's a stage, ..."; |
36 * | 36 * |
37 * [StringBuffer] provides a way to construct strings efficiently. | 37 * [StringBuffer] provides a way to construct strings efficiently. |
38 * | 38 * |
39 * StringBuffer moreShakespeare = new StringBuffer(); | 39 * StringBuffer moreShakespeare = new StringBuffer(); |
40 * moreShakespeare.write('And all the men and women '); | 40 * moreShakespeare.write('And all the men and women '); |
41 * moreShakespeare.write('merely players; ...'); | 41 * moreShakespeare.write('merely players; ...'); |
42 * | 42 * |
43 * The String and StringBuffer classes implement string concatenation, | 43 * The String and StringBuffer classes implement string concatenation, |
44 * interpolation, and other string manipulation features. | 44 * interpolation, and other string manipulation features. |
45 * | 45 * |
46 * String philosophy = 'Live on '; | 46 * String philosophy = 'Live on '; |
47 * String get palindrome => philosophy + philosophy.split('').reversed.join(
); | 47 * String get palindrome => philosophy + philosophy.split('').reversed.join(
); |
48 * | 48 * |
49 * [RegExp] implements Dart regular expressions, | 49 * [RegExp] implements Dart regular expressions, |
50 * which provide a grammar for matching patterns within text. | 50 * which provide a grammar for matching patterns within text. |
51 * For example, here's a regular expression that matches | 51 * For example, here's a regular expression that matches |
52 * a string of one or more digits: | 52 * a string of one or more digits: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 * Map sidekicks = { 'Batman': 'Robin', | 87 * Map sidekicks = { 'Batman': 'Robin', |
88 * 'Superman': 'Lois Lane', | 88 * 'Superman': 'Lois Lane', |
89 * 'Harry Potter': 'Ron and Hermione' }; | 89 * 'Harry Potter': 'Ron and Hermione' }; |
90 * | 90 * |
91 * In addition to these classes, | 91 * In addition to these classes, |
92 * dart:core contains [Iterable], | 92 * dart:core contains [Iterable], |
93 * an interface that defines functionality | 93 * an interface that defines functionality |
94 * common in collections of objects. | 94 * common in collections of objects. |
95 * Examples include the ability | 95 * Examples include the ability |
96 * to run a function on each element in the collection, | 96 * to run a function on each element in the collection, |
97 * to apply a test to each element, | 97 * to apply a test to each element, |
98 * to retrieve an object, and to determine length. | 98 * to retrieve an object, and to determine length. |
99 * | 99 * |
100 * Iterable is implemented by List and Set, | 100 * Iterable is implemented by List and Set, |
101 * and used by Map for its keys and values. | 101 * and used by Map for its keys and values. |
102 * | 102 * |
103 * For other kinds of collections, check out the | 103 * For other kinds of collections, check out the |
104 * [dart:collection](#dart-collection) library. | 104 * [dart:collection](#dart-collection) library. |
105 * | 105 * |
106 * ## Date and time | 106 * ## Date and time |
107 * | 107 * |
108 * Use [DateTime] to represent a point in time | 108 * Use [DateTime] to represent a point in time |
109 * and [Duration] to represent a span of time. | 109 * and [Duration] to represent a span of time. |
110 * | 110 * |
111 * You can create DateTime objects with constructors | 111 * You can create DateTime objects with constructors |
112 * or by parsing a correctly formatted string. | 112 * or by parsing a correctly formatted string. |
113 * | 113 * |
114 * DateTime now = new DateTime.now(); | 114 * DateTime now = new DateTime.now(); |
115 * DateTime berlinWallFell = new DateTime(1989, 11, 9); | 115 * DateTime berlinWallFell = new DateTime(1989, 11, 9); |
116 * DateTime moonLanding = DateTime.parse("1969-07-20"); | 116 * DateTime moonLanding = DateTime.parse("1969-07-20"); |
117 * | 117 * |
118 * Create a Duration object specifying the individual time units. | 118 * Create a Duration object specifying the individual time units. |
119 * | 119 * |
120 * Duration timeRemaining = new Duration(hours:56, minutes:14); | 120 * Duration timeRemaining = new Duration(hours:56, minutes:14); |
121 * | 121 * |
122 * In addition to DateTime and Duration, | 122 * In addition to DateTime and Duration, |
123 * dart:core contains the [Stopwatch] class for measuring elapsed time. | 123 * dart:core contains the [Stopwatch] class for measuring elapsed time. |
124 * | 124 * |
125 * ## Uri | 125 * ## Uri |
126 * | 126 * |
127 * A [Uri] object represents a uniform resource identifier, | 127 * A [Uri] object represents a uniform resource identifier, |
128 * which identifies a resource on the web. | 128 * which identifies a resource on the web. |
129 * | 129 * |
130 * Uri dartlang = Uri.parse('http://dartlang.org/'); | 130 * Uri dartlang = Uri.parse('http://dartlang.org/'); |
131 * | 131 * |
132 * ## Errors | 132 * ## Errors |
133 * | 133 * |
134 * The [Error] class represents the occurrence of an error | 134 * The [Error] class represents the occurrence of an error |
135 * during runtime. | 135 * during runtime. |
136 * Subclasses of this class represent specific kinds of errors. | 136 * Subclasses of this class represent specific kinds of errors. |
137 * | 137 * |
138 * ## Other documentation | 138 * ## Other documentation |
139 * | 139 * |
140 * For more information about how to use the built-in types, refer to | 140 * For more information about how to use the built-in types, refer to |
141 * [Built-in Types](http://www.dartlang.org/docs/dart-up-and-running/contents/ch
02.html#built-in-types) | 141 * [Built-in Types](http://www.dartlang.org/docs/dart-up-and-running/contents/ch
02.html#built-in-types) |
142 * in Chapter 2 of | 142 * in Chapter 2 of |
143 * [Dart: Up and Running](http://www.dartlang.org/docs/dart-up-and-running/). | 143 * [Dart: Up and Running](http://www.dartlang.org/docs/dart-up-and-running/). |
144 * | 144 * |
145 * Also, see | 145 * Also, see |
146 * [dart:core - Numbers, Collections, Strings, and More](http://www.dartlang.org
/docs/dart-up-and-running/contents/ch03.html#ch03-dartcore---strings-collections
-and-more) | 146 * [dart:core - Numbers, Collections, Strings, and More](http://www.dartlang.org
/docs/dart-up-and-running/contents/ch03.html#ch03-dartcore---strings-collections
-and-more) |
147 * for more coverage of classes in this package. | 147 * for more coverage of classes in this package. |
148 * | 148 * |
149 * The | 149 * The |
150 * [Dart Language Specification](http://www.dartlang.org/docs/spec/) | 150 * [Dart Language Specification](http://www.dartlang.org/docs/spec/) |
151 * provides technical details. | 151 * provides technical details. |
152 */ | 152 */ |
153 library dart.core; | 153 library dart.core; |
154 | 154 |
155 import "dart:collection"; | 155 import "dart:collection"; |
156 import "dart:_collection-dev" hide Symbol; | 156 import "dart:_collection-dev" hide Symbol; |
157 import "dart:_collection-dev" as _collection_dev; | 157 import "dart:_collection-dev" as _collection_dev; |
158 import "dart:convert" show UTF8, Encoding; | 158 import "dart:convert" show UTF8, Encoding; |
| 159 import "dart:math" show Random; // Used by List.shuffle. |
159 | 160 |
160 part "bool.dart"; | 161 part "bool.dart"; |
161 part "comparable.dart"; | 162 part "comparable.dart"; |
162 part "date_time.dart"; | 163 part "date_time.dart"; |
163 part "double.dart"; | 164 part "double.dart"; |
164 part "duration.dart"; | 165 part "duration.dart"; |
165 part "errors.dart"; | 166 part "errors.dart"; |
166 part "exceptions.dart"; | 167 part "exceptions.dart"; |
167 part "expando.dart"; | 168 part "expando.dart"; |
168 part "function.dart"; | 169 part "function.dart"; |
(...skipping 12 matching lines...) Expand all Loading... |
181 part "regexp.dart"; | 182 part "regexp.dart"; |
182 part "set.dart"; | 183 part "set.dart"; |
183 part "stacktrace.dart"; | 184 part "stacktrace.dart"; |
184 part "stopwatch.dart"; | 185 part "stopwatch.dart"; |
185 part "string.dart"; | 186 part "string.dart"; |
186 part "string_buffer.dart"; | 187 part "string_buffer.dart"; |
187 part "string_sink.dart"; | 188 part "string_sink.dart"; |
188 part "symbol.dart"; | 189 part "symbol.dart"; |
189 part "type.dart"; | 190 part "type.dart"; |
190 part "uri.dart"; | 191 part "uri.dart"; |
OLD | NEW |