Table of contents
TOC
Collapse the table of content
Expand the table of content

Array.contains<'T> Function (F#)

liboz|Last Updated: 8/18/2017

Evaluates to true if the given element is in the input array.

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

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

Syntax

// Signature:
Array.contains : 'T -> 'T [] -> bool

// Usage:
Array.contains element source

Parameters

element Type: 'T

The element to find.

source Type: 'T[]

The input array.

Exceptions

ExceptionCondition
ArgumentNullExceptionThrown when the input array is null.

Return Value

Evaluates to true if the given element is in the input array. Otherwise, it will return false.

Remarks

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

Example

The following code shows how to use Array.contains.

let array1 = [| 1 .. 10 |]
let array2 = Array.empty

//The following line prints true
printfn "%A" (Array.contains 5 array1)

//The following line prints false
printfn "%A" (Array.contains 5 array2)

Output

true
false

Platforms

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

Version Information

F# Core Library Versions

Supported in: 4.0, Portable

See Also

Collections.Array Module (F#)

Microsoft.FSharp.Collections Namespace (F#)

© 2018 Microsoft