Map.find<'Key,'T> 함수(F#)
맵의 요소를 조회합니다.맵에 바인딩이 없으면 KeyNotFoundException이 발생합니다.
네임스페이스/모듈 경로: Microsoft.FSharp.Collections.Map
어셈블리: FSharp.Core(FSharp.Core.dll)
// Signature:
Map.find : 'Key -> Map<'Key,'T> -> 'T (requires comparison)
// Usage:
Map.find key table
매개 변수
key
형식: 'Key입력 키입니다.
table
형식: Map<'Key,'T>입력 맵입니다.
예외
Exception |
조건 |
---|---|
키가 맵에 없는 경우 throw됩니다. |
반환 값
지정된 키에 매핑된 값입니다.
설명
컴파일된 어셈블리에서 이 함수의 이름은 Find입니다.F# 이외의 언어에서 함수에 액세스하거나 리플렉션을 통해 함수에 액세스하는 경우 이 이름을 사용합니다.
예제
다음 예제에서는 Map.filter의 사용 방법을 보여 줍니다.
let findAndPrint key map =
printfn "With key %d, found value %A." key (Map.find key map)
let map1 = Map.ofList [ (1, "one"); (2, "two"); (3, "three") ]
let map2 = Map.ofList [ for i in 1 .. 10 -> (i, i*i) ]
try
findAndPrint 1 map1
findAndPrint 2 map1
findAndPrint 3 map2
findAndPrint 5 map2
// The key is not in the map, so this throws an exception.
findAndPrint 0 map2
with
:? System.Collections.Generic.KeyNotFoundException as e -> printfn "%s" e.Message
Output
플랫폼
Windows Windows 서버 2012, Windows Server 2008 R2, Windows 7, 8
버전 정보
F# 코어 라이브러리 버전
지원: 2.0, 4.0, 노트북