Get immediate access to this and over 1,500+ other videos and books.

Boost your skills with a raywenderlich.com Beginner subscription. With over 60+ video courses and our core foundational programming books bundled in one subscription, it’s simply the best investment you can make in your development career.

Use Arrow Notation

This video was last updated on Jun 21 2022

Dart provides a nice little shortcut when writing functions called arrow notation. While it makes your functions easier to read, it raises questions about the void return type.

Contributors

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a raywenderlich.com Professional subscription.

Often times when you will write a function that is composed of a single line of code, you can actually shorthand to make a function a single line of code. You use what is known as arrow notation. It’s also known as fat arrow syntax or lambda syntax.

int add(int itemA, int itemB) {
    return itemA + itemB;
}
void main() {
    print(add(1, 2));
}
int add(int itemA, int itemB) => itemA + itemB;
void log(String message) => print(message);
void main() {
    log('this space is for rent');
}
void main() => log('this space is for rent');

Reviews

Comments