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

Tests whether an array is empty.

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

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

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

// Usage:
Array.isEmpty array

Parameters

  • array
    Type: 'T[]

    The input array.

Return Value

true if the array is empty. Otherwise, returns false.

Remarks

This function is named IsEmpty 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.isEmpty.

let printArray array1 = 
    if (Array.isEmpty array1) then
        printfn "There are no elements in this array." 
    else
        printfn "This array contains the following elements:"
        Array.iter (fun elem -> printf "%A " elem) array1
        printfn ""
printArray [| "test1"; "test2" |]
printArray [| |]

Output

This array contains the following elements:
"test1" "test2" 
There are no elements in this array.

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

Reference

Collections.Array Module (F#)

Microsoft.FSharp.Collections Namespace (F#)