Skip to content

Commit 17ff403

Browse files
authored
Fixes bad code sample for optional parameters in methods (#35528)
fixes #30383
1 parent 5477ce3 commit 17ff403

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

docs/fsharp/language-reference/members/methods.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ Overloaded methods are methods that have identical names in a given type but tha
9898
Starting with F# 4.1, you can also have optional arguments with a default parameter value in methods. This is to help facilitate interoperation with C# code. The following example demonstrates the syntax:
9999

100100
```fsharp
101+
open System.Runtime.InteropServices
101102
// A class with a method M, which takes in an optional integer argument.
102103
type C() =
103-
_.M([<Optional; DefaultParameterValue(12)>] i) = i + 1
104+
member _.M([<Optional; DefaultParameterValue(12)>] i) = i + 1
104105
```
105106

106107
Note that the value passed in for `DefaultParameterValue` must match the input type. In the above sample, it is an `int`. Attempting to pass a non-integer value into `DefaultParameterValue` would result in a compile error.

0 commit comments

Comments
 (0)