Name
removeAt — Remove an element from a list that is stored as a string
Usage
String.removeAt(str, index, sep)
: Stringstr
: Numberindex
: Stringsep
Description
(See elementAt( )
’s description for an
explanation of how a string is processed as a list of
“elements.”)
Starting with the list stored as string str
,
returns a list with the element at position
index
removed. (The first element has
index zero.) The separator is also removed, so the number of elements
in the list goes down by one. The return value is a new string;
str
itself remains unmodified.
If index
is past the end of the list, the
last element is removed. Similarly, if
index
is less than zero, the first element
is removed. If the string contains only one element, or is empty, an
empty string is returned. If index
is a
floating-point value, it’s first converted to an integer with
Float.int( )
.
Returns invalid
if any of the values can’t
be converted to the required types or if
sep
is the empty string.
Examples
String.removeAt("a;b;c;d", 2, ";")
returns string "a;b;d"
String.removeAt("a;b;c;d", -1, ";")
returns string "b;c;d"
String.removeAt("a;b;c;d", 6, ";")
returns string "a;b;c"
String.removeAt("a;b;c;d", 1.2, ";")
returns string "a;c;d"
String.removeAt("", 0, ";")
returns string ""
String.removeAt("x", 0, ";")
returns string ""
String.removeAt(invalid, 1, "x")
returns invalid
String.removeAt("foo", "two", "x")
returns invalid
String.removeAt("foo", 1, invalid)
returns invalid
String.removeAt("foo", 1, "")
returns invalid
Get Learning WML, and WMLScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.