Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Latest commit

 

History

History
87 lines (57 loc) · 1.98 KB

File metadata and controls

87 lines (57 loc) · 1.98 KB
title Map.find<'Key,'T> Function (F#)
description Map.find<'Key,'T> Function (F#)
keywords visual f#, f#, functional programming
author dend
manager danielfe
ms.date 05/16/2016
ms.topic language-reference
ms.prod visual-studio-dev14
ms.technology devlang-fsharp
ms.assetid a3b17fac-ce16-4798-81f2-5f208723c22f

Map.find<'Key,'T> Function (F#)

Looks up an element in the map. If no binding exists in the map, raises System.Collections.Generic.KeyNotFoundException.

Namespace/Module Path: Microsoft.FSharp.Collections.Map

Assembly: FSharp.Core (in FSharp.Core.dll)

Syntax

// Signature:
Map.find : 'Key -> Map<'Key,'T> -> 'T (requires comparison)

// Usage:
Map.find key table

Parameters

key Type: 'Key

The input key.

table Type: Map<'Key,'T>

The input map.

Exceptions

Exception Condition
KeyNotFoundException Thrown when the key does not exist in the map.

Return Value

The value mapped to the given key.

Remarks

This function is named Find in compiled assemblies. If you are accessing the function from a language other than F#, or through reflection, use this name.

Example

The following examples shows how to use Map.find.

[!code-fsharpMain]

Output

With key 1, found value "one".
With key 2, found value "two".
With key 3, found value 9.
With key 5, found value 25.
The given key was not present in the dictionary.

Platforms

Windows 8, Windows 7, Windows Server 2012, Windows Server 2008 R2

Version Information

F# Core Library Versions

Supported in: 2.0, 4.0, Portable

See Also

Collections.Map Module (F#)

Microsoft.FSharp.Collections Namespace (F#)