From 04625fb752560c7eceed976568f710ecb695b6e2 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Tue, 30 Mar 2021 21:33:30 +0800 Subject: [PATCH] Add literal string and continuation example. --- scripts/string.rhai | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/scripts/string.rhai b/scripts/string.rhai index 70ea201e..0bb799c5 100644 --- a/scripts/string.rhai +++ b/scripts/string.rhai @@ -2,8 +2,8 @@ print("hello"); print("this\nis \\ nice"); // escape sequences -print("40 hex is \x40"); // hex escape sequence -print("unicode fun: \u2764"); // Unicode escape sequence +print("0x40 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 @@ -15,3 +15,22 @@ print("length=" + s.len); // should be 17 s[s.len-3] = '?'; // change the string print("Question: " + s); // should print 'Question: hello, world?' + +// Line continuation: +let s = "This is a long \ + string constructed using \ + line continuation"; + +print("One string: " + s); + +// Multi-line literal string: +let s = ` + \U0001F603 This is a multi-line + "string" with \t\x20\r\n +made using multi-line literal + string syntax. +`; + +print(s); + +print(">>> END <<<");