The Hyper Programming Language

Class ‘string’

This is the class reference of built-in type string.

Warning: the interface of this class will change in the near future, because string will become a container for Unicode text that is encoded as UTF-8.

Class

sealed class string : object

This class represents a mutable array of char's.

Constructors

procedure new()

Default constructor. Creates an empty string.

procedure new(s : string)

Copy constructor.

procedure new(b : byte)

Explicit conversion constructor.

procedure new(c : char)

Explicit conversion constructor.

procedure new(d : double)

Explicit conversion constructor.

procedure new(i : int)

Explicit conversion constructor.

procedure new(i : int16)

Explicit conversion constructor.

procedure new(i : int32)

Explicit conversion constructor.

procedure new(i : int64)

Explicit conversion constructor.

procedure new(n : nat)

Explicit conversion constructor.

procedure new(n : nat16)

Explicit conversion constructor.

procedure new(n : nat32)

Explicit conversion constructor.

procedure new(n : nat64)

Explicit conversion constructor.

procedure new(r : real)

Explicit conversion constructor.

procedure new(s : single)

Explicit conversion constructor.

Procedures

procedure clear()

Clears the string, so that it becomes empty.

const procedure isEmpty() : bool

Returns true if the string is empty, i.e. has a zero length.

const procedure left(length : nat) : string

Returns a copy of the leftmost part of the string. length specifies the length of the part to be returned. If length exceeds the length of the original string, then the whole string is returned.

const procedure right(length : nat) : string

Returns a copy of the rightmost part of the string. length specifies the length of the part to be returned. If length exceeds the length of the original string, then the whole string is returned.

const procedure size() : nat

Returns the number of characters in the string.

const procedure subString(start & length : nat) : string

Returns a partial copy of the string. start indicates the index of what must become the first character of the substring (index 0 is the first character in a string). length specifies the length of the substring. If start + length > size() then the substring will not contain any characters that are not in the original string. (For example: "foobar".subString(4, 3) will return "ar")

Operators

Warning: this is preliminary syntax with the purpose of documenting the operators of this class. Nothing official yet!

Binary Operators

not yet documented

Assignment Operators

operator=(s : string)

Simple assignment operator.

operator+=(c : char)

Appends the given character to the end of the string.

operator+=(s : string)

Add a given string to the end of this string.

See also


Valid HTML 4.01 Strict Valid CSS!