Partager via


Array.isEmpty<'T>, fonction (F#)

Teste si un tableau est vide.

Espace de noms/Chemin du module : Microsoft.FSharp.Collections.Array

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

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

// Usage:
Array.isEmpty array

Paramètres

  • array
    Type : 'T[]

    Tableau d'entrée.

Valeur de retour

trueTrue si le tableau est vide.Sinon, retourne false.

Notes

Cette fonction se nomme IsEmpty dans les assemblys compilés.Si vous accédez à la fonction à partir d'un langage autre que F# ou par réflexion, utilisez ce nom.

Exemple

Le code suivant montre comment utiliser 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 [| |]

Sortie

  

Plateformes

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

Informations de version

Versions de bibliothèque principale F#

Prise en charge dans : 2,0, 4,0, portables

Voir aussi

Référence

Collections.Array, module (F#)

Microsoft.FSharp.Collections, espace de noms (F#)