Skip to content

Commit

Permalink
Add a short discussion of string concatenation to the FAQ. (#24487)
Browse files Browse the repository at this point in the history
  • Loading branch information
tpapp authored and StefanKarpinski committed Oct 18, 2018
1 parent 0a12576 commit 0bab957
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions doc/src/manual/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,17 @@ julia> remotecall_fetch(anon_bar, 2)
1
```

### Why does Julia use `*` for string concatenation? Why not `+` or something else?

The [main argument](@ref man-concatenation) against `+` is that string concatenation is not
commutative, while `+` is generally used as a commutative operator. While the Julia community
recognizes that other languages use different operators and `*` may be unfamiliar for some
users, it communicates certain algebraic properties.

Note that you can also use `string(...)` to concatenate strings (and other values converted
to strings); similarly, `repeat` can be used instead of `^` to repeat strings. The
[interpolation syntax](@ref string-interpolation) is also useful for constructing strings.

## Packages and Modules

### What is the difference between "using" and "import"?
Expand Down
2 changes: 1 addition & 1 deletion doc/src/manual/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ further discussion of UTF-8 encoding issues, see the section below on [byte arra
The [`transcode`](@ref) function is provided to convert data between the various UTF-xx encodings,
primarily for working with external data and libraries.

## Concatenation
## [Concatenation](@id man-concatenation)

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

Expand Down

0 comments on commit 0bab957

Please sign in to comment.