Map.Add<'Key,'Value> Method (F#)
Returns a new map with the binding added to the given map.
Namespace/Module Path: Microsoft.FSharp.Collections
Assembly: FSharp.Core (in FSharp.Core.dll)
// Signature:
member this.Add : 'Key * 'Value -> Map<'Key, 'Value> (requires comparison)
// Usage:
map.Add (key, value)
Parameters
key
Type: 'KeyThe input key.
value
Type: 'ValueThe input value.
Return Value
The resulting map.
Example
The following code example shows how to use the Add method.
let map1 = Map.ofList [ (1, "one"); (2, "two"); (3, "three") ]
let map2 = map1.Add(0, "zero")
map2 |> Map.iter (fun key value -> printfn "key: %d value: %s" key value)
Output
key: 0 value: zero key: 1 value: one key: 2 value: two key: 3 value: three
Platforms
Windows 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2
Version Information
F# Runtime
Supported in: 2.0, 4.0
Silverlight
Supported in: 3