For example, if I have a variable like this:
A = "Dog"; B = "Cat";
I can do this: C = "I have both $A and $b";
C = "I have both $A and $b";
How do I do something like the below and add today’s value, e.g., October 10, 2021? D = “I walked my $A and $B on $today()”.
Thanks.
Just add (): D = "I walked my $A and $B on $(today())"
D = "I walked my $A and $B on $(today())"
NB: using Dates
using Dates
julia> "If you want to confuse people, you can interpolate longer expressions: $(begin;a=3;b=a^2;b-1;end)" "If you want to confuse people, you can interpolate longer expressions: 8"
Don’t do this, but the fact that you can is pretty cool.
And begin; end; could be replaced by (): $((a=3;b=a^2;b-1))
begin
end
$((a=3;b=a^2;b-1))
And
Dates.format(today(), "U d, YYYY") "October 10, 2021"
does the formatting, returning a String.
Many thanks for all the replies. I learned many pieces of important knowledge about Julia.