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

Array.empty<'T> Type Function (F#)

Den Delimarsky|Last Updated: 6/8/2016
|
1 Contributor

Returns an empty array of the given type.

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

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

Syntax

// Signature:
Array.empty<'T> :  'T []

// Usage:
Array.empty

Return Value

An empty array.

Remarks

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

Example

The following code shows how to use Array.empty.


    // Specify the type by using a type argument.
    let array1 = Array.empty<int>
    // Specify the type by using a type annotation.
    let array2 : int array = Array.empty

    // Even though array3 has a generic type,
    // you can still use methods such as Length on it.
    let array3 = Array.empty
    printfn "Length of empty array: %d" array3.Length

Output

Length of empty array: 0

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

Collections.Array Module (F#)

Microsoft.FSharp.Collections Namespace (F#)

© 2016 Microsoft