LEARN VOID / DATA & BEHAVIOR

Strings & Unicode

Use one text type throughout ordinary code.

Illustrative fragment — place this code inside a function. It is verified in an executable context, but the download is not a standalone program.

strings.voidDownload fragment
var greeting = "Hello, "
const name = "世界"
var message = greeting + name
message += "!"

Create and combine text

The local fragment creates a greeting and a UTF-8 name, then combines them with +. After message += "!", the value is "Hello, 世界!". The code belongs inside a function; it does not print or return a value on its own.

Rebind without changing earlier text

+= assigns concatenated text back to the mutable message binding. It does not change greeting or the readonly name. String content is immutable; assignment can share that content safely. A defaultable uninitialized string local or field starts empty.

Understand Unicode and API limits

Strings compare exact UTF-8 content without Unicode normalization. Supported escapes include \n, \t and scalar escapes such as \u{e9}. Numeric concatenation, printing, interpolation, indexing and proposed text APIs are not implied by this example.