File tree Expand file tree Collapse file tree 2 files changed +2
-0
lines changed
docs/fsharp/language-reference Expand file tree Collapse file tree 2 files changed +2
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,7 @@ handleEvent "OrderCreated" "Order #123" // matches first case
9898```
9999
100100Using ` nameof ` instead of string literals like ` "OrderCreated" ` provides several benefits:
101+
101102- If you rename a discriminated union case, the pattern automatically updates.
102103- The compiler prevents typos by ensuring the symbol exists.
103104- Your code remains consistent during refactoring.
Original file line number Diff line number Diff line change @@ -260,6 +260,7 @@ handleEvent "OrderShipped" "Order #123" // matches second case
260260```
261261
262262This approach is better than using string literals (like ` "OrderCreated" ` ) because:
263+
263264- If you rename ` OrderCreated ` to ` OrderPlaced ` , the pattern automatically updates.
264265- The compiler ensures that the symbol exists, preventing typos.
265266- Your code remains consistent when refactoring.
You can’t perform that action at this time.
0 commit comments