This file contains 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
<!DOCTYPE html> | |
<!-- | |
Copyright (c) 2012, the Dart project authors. | |
Please see the AUTHORS file for details. | |
All rights reserved. Use of this source code | |
is governed by a BSD-style license that can be | |
found in the LICENSE file. | |
--> |
This file contains 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
<!DOCTYPE html> | |
<!-- | |
Copyright (c) 2012, the Dart project authors. | |
Please see the AUTHORS file for details. | |
All rights reserved. Use of this source code | |
is governed by a BSD-style license that can be | |
found in the LICENSE file. | |
--> |
This file contains 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
<!DOCTYPE html> | |
<!-- | |
Copyright (c) 2012, the Dart project authors. | |
Please see the AUTHORS file for details. | |
All rights reserved. Use of this source code | |
is governed by a BSD-style license that can be | |
found in the LICENSE file. | |
--> |
This file contains 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
String scream(int length) { | |
return "A${'a' * length}h!"; | |
} | |
main() { | |
var values = [1, 2, 3, 5, 10, 50]; | |
values.skip(1).take(3).map(scream).forEach(print); | |
} |
This file contains 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
String scream(int length) { | |
return "A${'a' * length}h!"; | |
} | |
main() { | |
var values = [1, 2, 3, 5, 10, 50]; | |
values.map(scream).forEach(print); | |
} |
This file contains 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
String scream(int length) { | |
return "A${'a' * length}h!"; | |
} | |
main() { | |
var values = [1, 2, 3, 5, 10, 50]; | |
for (var length in values) { | |
print(scream(length)); | |
} | |
} |
This file contains 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
import 'dart:math'; | |
abstract class Shape { | |
factory Shape(String type) { | |
if (type == "circle") return new Circle(2); | |
if (type == "square") return new Square(2); | |
throw new ArgumentError("Can't create $type."); | |
} | |
num get area; | |
} |
This file contains 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
import 'dart:math'; | |
abstract class Shape { | |
factory Shape(String type) { | |
if (type == 'circle') return new Circle(2); | |
if (type == 'square') return new Square(2); | |
throw 'Can\'t create $type.'; | |
} | |
num get area; | |
} |
This file contains 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
import 'dart:math'; | |
abstract class Shape { | |
num get area; | |
} | |
class Circle implements Shape { | |
final num radius; | |
Circle(this.radius); | |
num get area => PI * pow(radius, 2); |
This file contains 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
import 'dart:math'; | |
abstract class Shape { | |
num get area; | |
} | |
class Circle implements Shape { | |
final num radius; | |
Circle(this.radius); | |
num get area => PI * pow(radius, 2); |