2020-03-16 07:50:12 +01:00
|
|
|
// This script tests string operations
|
|
|
|
|
2016-03-02 14:37:28 +01:00
|
|
|
print("hello");
|
2020-03-16 07:50:12 +01:00
|
|
|
print("this\nis \\ nice"); // escape sequences
|
|
|
|
print("40 hex is \x40"); // hex escape sequence
|
|
|
|
print("unicode fun: \u2764"); // Unicode escape sequence
|
|
|
|
print("more fun: \U0001F603"); // Unicode escape sequence
|
|
|
|
print("foo" + " " + "bar"); // string building using strings
|
|
|
|
print("foo" < "bar"); // string comparison
|
|
|
|
print("foo" >= "bar"); // string comparison
|
|
|
|
print("the answer is " + 42); // string building using non-string types
|
|
|
|
|
|
|
|
let s = "hello, world!"; // string variable
|
2020-05-30 04:30:21 +02:00
|
|
|
print("length=" + s.len); // should be 13
|
2020-03-16 07:50:12 +01:00
|
|
|
|
2020-05-30 04:30:21 +02:00
|
|
|
s[s.len-1] = '?'; // change the string
|
|
|
|
print("Question: " + s); // should print 'Question: hello, world?'
|