Skip to content

Files

Latest commit

 

History

History
47 lines (36 loc) · 865 Bytes

prefer_expression_function_bodies.md

File metadata and controls

47 lines (36 loc) · 865 Bytes

Pattern: Missing use of =>

Issue: -

Description

CONSIDER using => for short members whose body is a single return statement.

Example of incorrect code:

get width {
 return right - left;
}

Example of incorrect code:

bool ready(num time) {
 return minTime == null || minTime <= time;
}

Example of incorrect code:

containsValue(String value) {
 return getValues().contains(value);
}

Example of correct code:

get width => right - left;

Example of correct code:

bool ready(num time) => minTime == null || minTime <= time;

Example of correct code:

containsValue(String value) => getValues().contains(value);

Further Reading