Tuesday, 16 February 2016

Julia: $: Evaluate expression inside string literal


By using ‘$’, you can evaluate an expression inside string literal.
julia> message="Welcome";name="Hari";

julia> info="$message,$name"
"Welcome,Hari"

julia> data="1+2=$(1+2)";

julia> data
"1+2=3"


To include $ in string literal, you have to use \.
julia> message="Today revenue is \$100";

julia> print(message)
Today revenue is $100



Previous                                                 Next                                                 Home

No comments:

Post a Comment