Skip to content
Menu
Contents

Reading the tags

pure

Same arguments, same result; touches nothing outside.

pure if arg2 is

Pure when that argument is a pure function; otherwise as impure as it is.

impure

Reads or changes something outside the program.

String

1 type1 value17 functions

Functions on Strings, which are UTF-8 byte sequences. Lengths and offsets count bytes; UTF8.codePoints reads a string as characters. == compares strings byte for byte, as eq does.

String.join(String.split("a,b,c", ","), " ")
Returns
"a b c"

At a glance

  • @Builder

    A string being built by appending, each append amortized constant time: append writes into a buffer that grows to the next power of two when it runs out of room, rather than copying the string so far, and build makes the String.

  • builder

    The builder holding no bytes yet.

  • concat

    The two strings one after the other.

  • eq

    Byte equality.

  • ne

    true when the strings differ in any byte.

  • split

    Every piece between occurrences of the separator, in order: split("a,b,", ",") is ["a", "b", ""].

  • join

    The strings with the separator between each two of them.

  • trim

    Without leading and trailing ASCII whitespace: space, tab, \n, \r, form feed and vertical tab.

  • lowercaseAscii

    Each ASCII letter A to Z as its lowercase a to z; every other byte, a non-ASCII letter's included, is left as it is.

  • contains

    Every string contains the empty string.

  • startsWith

    Every string starts with the empty string.

  • endsWith

    Every string ends with the empty string.

  • byteLength

    The length in UTF-8 bytes, not in code points.

  • sliceBytes

    The bytes from offset start up to, not including, offset end.

  • fromCodePoint

    The one-code-point string encoding a code point in UTF-8.

  • append

    The builder holding the bytes of b followed by those of s.

  • appendSlice

    append of the bytes of s from offset start up to, not including, offset end, held to s as sliceBytes holds them, without building the slice.

  • appendWrapped

    append of open, s and close, one after the other, as one step: appendWrapped(b, "\"", s, "\"") appends s in quotes.

  • build

    The string of every byte appended so far.

Types

@Builder

type @Builder

A string being built by appending, each append amortized constant time: append writes into a buffer that grows to the next power of two when it runs out of room, rather than copying the string so far, and build makes the String. A builder is a value like any other: appending to one gives a new builder and leaves the old one as it was, so it may be appended to again.

Values

builder

The builder holding no bytes yet.

Functions

concat

(String, String) -> Stringpure

The two strings one after the other.

eq

(String, String) -> Boolpure

Byte equality. A string-literal pattern compares through this too.

ne

(String, String) -> Boolpure

true when the strings differ in any byte.

split

(String, String) -> List(String)pure

Every piece between occurrences of the separator, in order: split("a,b,", ",") is ["a", "b", ""]. An empty separator does not split at all, so split(s, "") is [s], and split("", ",") is [""].

join

(List(String), String) -> Stringpure

The strings with the separator between each two of them.

trim

(String) -> Stringpure

Without leading and trailing ASCII whitespace: space, tab, \n, \r, form feed and vertical tab. Other whitespace, such as a no-break space, stays.

lowercaseAscii

(String) -> Stringpure

Each ASCII letter A to Z as its lowercase a to z; every other byte, a non-ASCII letter's included, is left as it is.

contains

(String, String) -> Boolpure

Every string contains the empty string.

startsWith

(String, String) -> Boolpure

Every string starts with the empty string.

endsWith

(String, String) -> Boolpure

Every string ends with the empty string.

byteLength

(String) -> Intpure

The length in UTF-8 bytes, not in code points.

sliceBytes

(String, Int, Int) -> Stringpure

The bytes from offset start up to, not including, offset end. Both are held to 0 … byteLength(s) first, and an end at or before start is the empty string. The offsets count bytes, so a cut inside a code point leaves part of its UTF-8 sequence on either side.

fromCodePoint

(Int) -> Stringpure

The one-code-point string encoding a code point in UTF-8. A value outside 0 … 0x10FFFF is U+FFFD; a surrogate is encoded as it is. The inverse of UTF8.codePoints.

append

(@Builder, String) -> @Builderpure

The builder holding the bytes of b followed by those of s. The bytes are written in place when b is the newest builder on its buffer and the buffer has room. Otherwise they are copied, after b's own bytes, into a new buffer: the smallest power of two that holds both.

appendSlice

(@Builder, String, Int, Int) -> @Builderpure

append of the bytes of s from offset start up to, not including, offset end, held to s as sliceBytes holds them, without building the slice.

appendWrapped

(@Builder, String, String, String) -> @Builderpure

append of open, s and close, one after the other, as one step: appendWrapped(b, "\"", s, "\"") appends s in quotes.

build

(@Builder) -> Stringpure

The string of every byte appended so far. Appending to the builder afterwards leaves it as it is. Building from the newest builder on a buffer copies nothing; the string then holds the buffer, room to grow included.

Reading the tags

pure

Same arguments, same result; touches nothing outside.

pure if arg2 is

Pure when that argument is a pure function; otherwise as impure as it is.

impure

Reads or changes something outside the program.