Skip to content

Commit 0bab957

Browse files
tpappStefanKarpinski
authored andcommitted
Add a short discussion of string concatenation to the FAQ. (#24487)
1 parent 0a12576 commit 0bab957

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

doc/src/manual/faq.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,17 @@ julia> remotecall_fetch(anon_bar, 2)
637637
1
638638
```
639639

640+
### Why does Julia use `*` for string concatenation? Why not `+` or something else?
641+
642+
The [main argument](@ref man-concatenation) against `+` is that string concatenation is not
643+
commutative, while `+` is generally used as a commutative operator. While the Julia community
644+
recognizes that other languages use different operators and `*` may be unfamiliar for some
645+
users, it communicates certain algebraic properties.
646+
647+
Note that you can also use `string(...)` to concatenate strings (and other values converted
648+
to strings); similarly, `repeat` can be used instead of `^` to repeat strings. The
649+
[interpolation syntax](@ref string-interpolation) is also useful for constructing strings.
650+
640651
## Packages and Modules
641652

642653
### What is the difference between "using" and "import"?

doc/src/manual/strings.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ further discussion of UTF-8 encoding issues, see the section below on [byte arra
404404
The [`transcode`](@ref) function is provided to convert data between the various UTF-xx encodings,
405405
primarily for working with external data and libraries.
406406

407-
## Concatenation
407+
## [Concatenation](@id man-concatenation)
408408

409409
One of the most common and useful string operations is concatenation:
410410

0 commit comments

Comments
 (0)