Skip to content

Commit

Permalink
website/ref/language.md: Document exploding strings.
Browse files Browse the repository at this point in the history
This fixes #1243.
  • Loading branch information
xiaq committed Dec 31, 2024
1 parent 53f77e6 commit b31cc81
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion website/ref/language.md
Original file line number Diff line number Diff line change
Expand Up @@ -907,10 +907,24 @@ the variable:
▶ bar
```

Exploding a string results in substrings, each containing an individual
codepoints (equivalent to calling [`str:split`](str.html#str:split) with an
empty separator):

```elvish-transcript
~> var s = 'Hi 世界'
~> put $@s
▶ H
▶ i
▶ ' '
▶ 世
▶ 界
```

**Note**: Since variable uses have higher precedence than [indexing](#indexing),
this does not work for exploding a list that is an element of another list. For
doing that, and exploding the result of other expressions (such as an output
capture), use the builtin [all](builtin.html#all) command.)
capture), use the builtin [all](builtin.html#all) command.

## Output capture

Expand Down

0 comments on commit b31cc81

Please sign in to comment.