IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: 1.0.0b1
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

len

len(value: StringSlice) -> Int

Get the string length.

Deprecated: Using String.len() is discouraged, prefer .byte_length() or .count_codepoints()

Args:

  • value (StringSlice): The object to get the length of.

Returns:

Int: The length of this value.

len[T: Sized](value: T) -> Int

Get the length of a value.

Parameters:

  • T (Sized): The Sized type.

Args:

  • value (T): The object to get the length of.

Returns:

Int: The length of the object.

len[T: SizedRaising](value: T) -> Int

Get the length of a value.

Parameters:

Args:

  • value (T): The object to get the length of.

Returns:

Int: The length of the object.

Raises:

If the length cannot be computed.