This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var a = [1, 12, 42]; | |
| print(a.join(", ")); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var data = [0.06, 0.82, -0.01, -0.34, -0.55]; | |
| var s = data.map((v) => v * v).reduce((sum, v) => sum + v); | |
| print(s); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var items = ["a", "b", "b", "aaa", "c", "a", "d"]; | |
| print('items has ${items.length} elements'); | |
| var c = items.toSet().length; | |
| print('items has ${c} distinct elements'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var x = new Set<String>(); | |
| x.add("foo"); | |
| x.add("bar"); | |
| var e = "baz"; | |
| x.add(e); | |
| print(x); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var x = new Set<String>(); | |
| x.add("foo"); | |
| x.add("bar"); | |
| x.add("baz"); | |
| print(x); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var x = new Set<String>(); | |
| x.add("foo"); | |
| { | |
| var e = "foo"; | |
| var b = x.contains(e); | |
| print('x contains ${e}: ${b}'); | |
| } | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var a = "Hello"; | |
| var b = " Universe"; | |
| var s = a + b; | |
| print(s); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| var a = "Hello"; | |
| var b = " Universe"; | |
| var s = '$a$b'; | |
| print(s); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main() { | |
| var data = ["Hello", "the", "world", "ham", "Tower", "WASP"]; | |
| data.sort((a, b) => a.toUpperCase().compareTo(b.toUpperCase())); | |
| print(data); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| main() { | |
| var items = ["foo", "bar"]; | |
| print(items.any((element) => element == "baz") | |
| ? "found it" | |
| : "did not find it"); | |
| items = ["foo", "bar", "baz"]; | |
| print(items.any((element) => element == "baz") |