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/language-reference/members/methods.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,9 +98,10 @@ Overloaded methods are methods that have identical names in a given type but tha
98
98
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:
99
99
100
100
```fsharp
101
+
open System.Runtime.InteropServices
101
102
// A class with a method M, which takes in an optional integer argument.
102
103
type C() =
103
-
_.M([<Optional; DefaultParameterValue(12)>] i) = i + 1
104
+
member _.M([<Optional; DefaultParameterValue(12)>] i) = i + 1
104
105
```
105
106
106
107
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