Length

Length( value )
Length( value )
Length( value )
Length( value )
length( value )
Length( value )

Description

The length function returns the number of characters in the provided string.

Although we mention characters, technically, we are talking about code points. In Unicode, a code point is usually, but not always, a character. Code points can sometimes represent single characters, but can also represent formatting and other non-alphanumeric characters.

For example, the character é can be the single character "e" that includes an acute accent (U+00E9), or it could be displayed as a single character but be composed of an "e" (U+0065) and a "combining" acute accent (U+0301). Visually, you cannot distinguish between the two.

Parameters

Argument Type Definition and Requirements

value

The string that should have its characters counted.

Returns

An integer that reports the number of characters in the string.

Examples

Value result = await client.Query(
    Arr(
        Length("fire"),
        Length("fire and fireman"),
        Length("")
    )
);

Console.WriteLine(result);
Arr(LongV(4), LongV(16), LongV(0))
result, err := client.Query(
	f.Arr{
		f.Length("fire"),
		f.Length("fire and fireman"),
		f.Length(""),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
[4 16 0]
System.out.println(
    client.query(
        Arr(
            Length("fire"),
            Length("fire and fireman"),
            Length("")
        )
    ).get());
[4, 16, 0]
client.query(
  [
    q.Length('fire'),
    q.Length('fire and fireman'),
    q.Length(''),
  ]
)
.then((ret) => console.log(ret))
.catch((err) => console.error('Error: %s', err))
[ 4, 16, 0 ]
result = client.query(
  [
    q.length("fire"),
    q.length("fire and fireman"),
    q.length(""),
  ]
)
print(result)
[4, 16, 0]
println(Await.result(
    client.query(
        Arr(
            Length("fire"),
            Length("fire and fireman"),
            Length("")
        )
    ),
    5.seconds
))
[4, 16, 0]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve!
Visit Fauna's Discourse forums or email docs@fauna.com

Thank you for your feedback!