Skip to content

Commit 76a8139

Browse files
author
Jan Nils Ferner
authored
Merge branch 'master' into switch-expression
2 parents bd75550 + 6b8fbc8 commit 76a8139

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

documentation/src/basic-constructs.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ return condition
6565
```
6666
*ternary operator*
6767

68-
## switch expression
68+
## Switch Expression
6969

7070
Prefer switch expressions over switch statements.
7171

@@ -79,6 +79,19 @@ return animalKind switch
7979
```
8080
*switch expression*
8181

82+
## Expression-bodied Members
83+
84+
Use the expression body syntax when a member returns a single expression.
85+
Move the arrow to the next line when the expression gets too long.
86+
87+
```csharp
88+
public int Length => 0;
89+
90+
public string AbsolutePath()
91+
=> Path.Combine(CalculateRootPath(), RelativePath);
92+
```
93+
*expression-bodied members*
94+
8295
## For-loops
8396

8497
Avoid for-loops and use LINQ and higher order functions as an alternative.

0 commit comments

Comments
 (0)