December 2018
Beginner to intermediate
500 pages
12h 10m
English
When creating longer, more complex strings, concatenation can be noisy and error-prone. For such cases, we're better off using the $ symbol to perform variable interpolation into strings:
julia> username = "Adrian" julia> greeting = "Good morning" julia> "$greeting, $username" "Good morning, Adrian"
More complex expressions can be interpolated by wrapping them into $(...):
julia> "$(uppercase(greeting)), $(reverse(username))" "GOOD MORNING, nairdA"
Here we invoke the uppercase function which changes all the letters of the string into their uppercase counterparts—and the reverse function which reverses the order of the letters in the word. Their output is then interpolated in a string. Between the $(...) boundaries, ...
Read now
Unlock full access