Content deleted Content added
minor visual fix |
brackets visual fix |
||
Line 377:
Age : int }
</syntaxhighlight>
Records can be created as {{code|lang=fsharp|code=let r = { Name="AB"; Age=42 } }}. The <code>with</code> keyword is used to create a copy of a record, as in {{code|lang=fsharp|code={ r with Name="CD" } }}, which creates a new record by copying <code>r</code> and changing the value of the <code>Name</code> field (assuming the record created in the last example was named <code>r</code>).
A [[tagged union|discriminated union]] type is a [[type-safe]] version of [[union (computer science)|C unions]]. For example,
Line 421:
Like other [[Common Language Infrastructure]] (CLI) languages, F# can use CLI types through object-oriented programming.<ref name="overview"/> F# support for object-oriented programming in expressions includes:
* Dot-notation, e.g., {{code|lang=fsharp|code=x.Name}}
* Object expressions, e.g., {{ code|lang=fsharp| code={ new obj() with member x.ToString() = "hello" } }}
* Object construction, e.g., {{code|lang=fsharp|code=new Form()}}
* Type tests, e.g., {{code|lang=fsharp|code=x :? string}}
|