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

업데이트: 2010년 8월

맵에서 요소를 조회하여 요소가 맵의 도메인에 있으면 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 7, Windows Vista SP2, Windows XP SP3, Windows XP x64 SP2, Windows Server 2008 R2, Windows Server 2008 SP2, Windows Server 2003 SP2

버전 정보

F# 런타임

지원되는 버전: 2.0, 4.0

Silverlight

지원되는 버전: 3

참고 항목

참조

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

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

변경 기록

날짜

변경 내용

이유

2010년 8월

코드 예제를 추가했습니다.

향상된 기능 관련 정보