| OLD | NEW |
| 1 --- | 1 --- |
| 2 layout: default | 2 layout: default |
| 3 title: "A Tour of the Dart Libraries" | 3 title: "A Tour of the Dart Libraries" |
| 4 description: "Learn how to use each major Dart library feature." | 4 description: "Learn how to use each major Dart library feature." |
| 5 --- | 5 --- |
| 6 | 6 |
| 7 # {{ page.title }} | 7 # {{ page.title }} |
| 8 | 8 |
| 9 Welcome to the Dart library tour! | 9 Welcome to the Dart library tour! |
| 10 We'll show you how to use the major features in each library | 10 We'll show you how to use the major features in each library |
| 11 that comes with Dart. | 11 that comes with Dart. |
| 12 | 12 |
| 13 This tour is just an overview of | 13 This tour is just an overview of |
| 14 library functionality; it is by no means comprehensive. | 14 library functionality; it is by no means comprehensive. |
| 15 Consult the | 15 Consult the |
| 16 [Dart API reference](http://api.dartlang.org/) | 16 [Dart API reference](http://api.dartlang.org/) |
| 17 for the full details about a class or interface. | 17 for the full details about a class or interface. |
| 18 | 18 |
| 19 <aside class="note" markdown="1"> | 19 <aside> |
| 20 **Note:** Expect major changes to the Dart libraries before Dart's | 20 <div class="alert"> |
| 21 first release. | 21 <strong>Warning:</strong> |
| 22 Expect major changes to the Dart libraries before Dart's |
| 23 first release. |
| 24 </div> |
| 22 </aside> | 25 </aside> |
| 23 | 26 |
| 24 #### Contents {#toc} | 27 #### Contents {#toc} |
| 25 | 28 |
| 26 1. [dart:core - Strings, collections, and more](#dartcore---strings-collections-
and-more) | 29 1. [dart:core - Strings, collections, and more](#dartcore---strings-collections-
and-more) |
| 27 1. [Collections](#collections) | 30 1. [Collections](#collections) |
| 28 1. [Lists](#lists) | 31 1. [Lists](#lists) |
| 29 1. [Sets](#sets) | 32 1. [Sets](#sets) |
| 30 1. [Common collection methods](#common-collection-methods) | 33 1. [Common collection methods](#common-collection-methods) |
| 31 1. [Maps (aka dictionaries or hashes)](#maps-aka-dictionaries-or-hashes) | 34 1. [Maps (aka dictionaries or hashes)](#maps-aka-dictionaries-or-hashes) |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 | 314 |
| 312 The [Map](http://api.dartlang.org/dart_core/Map.html) | 315 The [Map](http://api.dartlang.org/dart_core/Map.html) |
| 313 interface, commonly known as a _dictionary_ or _hash_, | 316 interface, commonly known as a _dictionary_ or _hash_, |
| 314 is an unordered collection of key-value pairs. | 317 is an unordered collection of key-value pairs. |
| 315 Maps associate a key to some value for easy retrieval. | 318 Maps associate a key to some value for easy retrieval. |
| 316 Unlike in JavaScript, Dart objects are not maps. | 319 Unlike in JavaScript, Dart objects are not maps. |
| 317 | 320 |
| 318 The language tour has more | 321 The language tour has more |
| 319 [information about maps](/docs/language-tour/#maps). | 322 [information about maps](/docs/language-tour/#maps). |
| 320 | 323 |
| 321 <aside class="note"> | 324 <aside> |
| 322 <b>Note:</b> The Map | 325 <div class="alert alert-info"> |
| 323 interface does not extend Collection. | 326 <strong>Note:</strong> |
| 327 The Map |
| 328 interface does not extend Collection. |
| 329 </div> |
| 324 </aside> | 330 </aside> |
| 325 | 331 |
| 326 ##### Creating maps | 332 ##### Creating maps |
| 327 | 333 |
| 328 You can declare a map using a terse literal syntax, | 334 You can declare a map using a terse literal syntax, |
| 329 or you can use a traditional constructor. | 335 or you can use a traditional constructor. |
| 330 | 336 |
| 331 {% highlight dart %} | 337 {% highlight dart %} |
| 332 // Map literals use strings as keys. | 338 // Map literals use strings as keys. |
| 333 var hawaiianBeaches = { | 339 var hawaiianBeaches = { |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 | 664 |
| 659 // Specify the number of significant figures. | 665 // Specify the number of significant figures. |
| 660 assert(123.456.toStringAsPrecision(2) == '1.2e+2'); | 666 assert(123.456.toStringAsPrecision(2) == '1.2e+2'); |
| 661 assert(Math.parseDouble('1.2e+2') == 120.0); | 667 assert(Math.parseDouble('1.2e+2') == 120.0); |
| 662 {% endhighlight %} | 668 {% endhighlight %} |
| 663 | 669 |
| 664 #### Trigonometry | 670 #### Trigonometry |
| 665 | 671 |
| 666 Use the Math class for the basic trigonometric functions. | 672 Use the Math class for the basic trigonometric functions. |
| 667 | 673 |
| 668 <aside class="note"> | 674 <aside> |
| 669 <b>Note:</b> These methods use radians, not degrees! | 675 <div class="alert alert-info"> |
| 676 <strong>Tip:</strong> |
| 677 These methods use radians, not degrees! |
| 678 </div> |
| 670 </aside> | 679 </aside> |
| 671 | 680 |
| 672 {% highlight dart %} | 681 {% highlight dart %} |
| 673 // Cosine | 682 // Cosine |
| 674 assert(Math.cos(Math.PI) == -1.0); | 683 assert(Math.cos(Math.PI) == -1.0); |
| 675 | 684 |
| 676 // Sine | 685 // Sine |
| 677 var degrees = 30; | 686 var degrees = 30; |
| 678 var radians = degrees * (Math.PI / 180); | 687 var radians = degrees * (Math.PI / 180); |
| 679 // radians is now 0.52359. | 688 // radians is now 0.52359. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 705 {% endhighlight %} | 714 {% endhighlight %} |
| 706 | 715 |
| 707 #### Random numbers | 716 #### Random numbers |
| 708 | 717 |
| 709 Generate random numbers between 0.0 and 1.0 with the Math class. | 718 Generate random numbers between 0.0 and 1.0 with the Math class. |
| 710 | 719 |
| 711 {% highlight dart %} | 720 {% highlight dart %} |
| 712 var rand = Math.random(); | 721 var rand = Math.random(); |
| 713 {% endhighlight %} | 722 {% endhighlight %} |
| 714 | 723 |
| 715 <aside class="note"> | 724 <aside> |
| 716 <b>Note:</b> The current implementation of random() for the | 725 <div class="alert alert-info"> |
| 717 Dart VM is not random at all. Follow | 726 <strong>Note:</strong> |
| 718 <a href="http://code.google.com/p/dart/issues/detail?id=499">bug 499</a> | 727 The current implementation of random() for the |
| 719 for the status. | 728 Dart VM is not random at all. Follow |
| 729 <a href="http://code.google.com/p/dart/issues/detail?id=499">bug 499</a> |
| 730 for the status. |
| 731 </div> |
| 720 </aside> | 732 </aside> |
| 721 | 733 |
| 722 #### More information | 734 #### More information |
| 723 | 735 |
| 724 Refer to the full | 736 Refer to the full |
| 725 [Math API docs](http://api.dartlang.org/dart_core/Math.html) | 737 [Math API docs](http://api.dartlang.org/dart_core/Math.html) |
| 726 for a full list of methods. | 738 for a full list of methods. |
| 727 Also see the API docs for | 739 Also see the API docs for |
| 728 [num](http://api.dartlang.org/dart_core/num.html), | 740 [num](http://api.dartlang.org/dart_core/num.html), |
| 729 [int](http://api.dartlang.org/dart_core/int.html), | 741 [int](http://api.dartlang.org/dart_core/int.html), |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 assert(base64 == | 1642 assert(base64 == |
| 1631 "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38G" | 1643 "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38G" |
| 1632 "IAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="); | 1644 "IAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="); |
| 1633 } | 1645 } |
| 1634 {% endhighlight %} | 1646 {% endhighlight %} |
| 1635 | 1647 |
| 1636 [Back to contents.](#toc) | 1648 [Back to contents.](#toc) |
| 1637 {:.up-to-toc} | 1649 {:.up-to-toc} |
| 1638 | 1650 |
| 1639 | 1651 |
| OLD | NEW |