Map.TryFind<'Key,'Value> 메서드(F#)

맵에서 요소를 조회하여 요소가 맵의 도메인에 있으면 Some 값을 반환하고, 그렇지 않으면 None을 반환합니다.

네임스페이스/모듈 경로:: Microsoft.FSharp.Collections

어셈블리: FSharp.Core(FSharp.Core.dll)

// Signature:
member this.TryFind : 'Key -> 'Value option (requires comparison)

// Usage:
map.TryFind (key)

매개 변수

  • key
    형식: 'Key

    입력 키입니다.

반환 값

매핑된 값이거나, 키가 맵에 없으면 None입니다.

예제

다음 코드는 TryFind 메서드를 사용하는 방법을 보여 줍니다.

let map1 = [ for i in 1 .. 100 -> (i, i*i) ] |> Map.ofList
let result = map1.TryFind 50
match result with
| Some x -> printfn "Found %d." x
| None -> printfn "Did not find the specified value."

Output

  

플랫폼

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

버전 정보

F# 코어 라이브러리 버전

지원: 2.0, 4.0, 노트북

참고 항목

참조

Collections.Map<'Key,'Value> 클래스(F#)

Microsoft.FSharp.Collections 네임스페이스(F#)