You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/fsharp/style-guide/formatting.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -892,6 +892,46 @@ else
892
892
e4
893
893
```
894
894
895
+
If a condition is long, place it on the next line with an extra indent.
896
+
Align the `if` and the `then` keywords.
897
+
898
+
```fsharp
899
+
if
900
+
complexExpression a b && env.IsDevelopment()
901
+
|| secondLongerExpression
902
+
aVeryLongparameterNameOne
903
+
aVeryLongparameterNameTwo
904
+
aVeryLongparameterNameThree
905
+
"""
906
+
Multiline
907
+
string
908
+
"""
909
+
then
910
+
e1
911
+
else
912
+
e2
913
+
```
914
+
915
+
If you have a condition that is this long, first consider refactoring it into a separate function and calling that function instead
916
+
917
+
```fsharp
918
+
let condition () =
919
+
complexExpression a b && env.IsDevelopment()
920
+
|| secondLongerExpression
921
+
aVeryLongparameterNameOne
922
+
aVeryLongparameterNameTwo
923
+
aVeryLongparameterNameThree
924
+
"""
925
+
Multiline
926
+
string
927
+
"""
928
+
929
+
if condition () then
930
+
e1
931
+
else
932
+
e2
933
+
```
934
+
895
935
### Pattern matching constructs
896
936
897
937
Use a `|` for each clause of a match with no indentation. If the expression is short, you can consider using a single line if each subexpression is also simple.
0 commit comments