// A simple function definition
yell(str) => str.toUpperCase();
// Functions can have type annotations
List lines(String str) {
return str.split('\n');
}
main() {
var poemLines = lines(poem);
print(yell(poemLines.first));
// functions are first-class
var whisper = (String str) => str.toLowerCase();
print(poemLines.map(whisper).last);
}
const poem = '''
The wren
Earns his living
Noiselessly.''';
$ dart functions.dart
THE WREN
noiselessly.