使用连接运算符- *运算符在 Julia 中添加字符串
*
是 julia 中的连接运算符,用于将不同的字符串和/或字符连接成单个字符串。
Syntax:
*(s::Union{AbstractString, AbstractChar}, t::Union{AbstractString, AbstractChar}…)
Parameters:
- Union{AbstractString, AbstractChar}: Specified strings or characters
Returns: It returns a new concatenated string.
示例 1:
# Julia program to illustrate
# the use of concatenate operator *
# Get concatenation of different strings
println("Geeks" * "forGeeks")
println("GFG" * " gfg")
println("Geeks" * "for" * "Geeks")
println("a" * "b")
println("a" * " b" * " c")
输出:
GeeksforGeeks
GFG gfg
GeeksforGeeks
ab
a b c
示例 2:
# Julia program to illustrate
# the use of concatenate operator *
# Get concatenation of different strings
println("1" * "-2")
println("1" * ", 3" * ", 5")
println("2" * " 4" * " 6" * " 8")
输出:
1-2
1, 3, 5
2 4 6 8