On 09/14/2018 05:33 PM, Brad Gilbert wrote:
On Fri, Sep 14, 2018 at 7:10 PM ToddAndMargo <toddandma...@zoho.com> wrote:

On 09/14/2018 04:37 PM, Brandon Allbery wrote:

  "{$x}::{$y}"

Most of my programming before Perl 5 was bash.  I
did a lot of "${x}abc" to keep the variables
from being confused with each other.

I carried the practice over to perl 6 with
"{$x}abc" but the developers over on the chat
line told me not to do it.  I don't remember why,
(I just do everything they tell me.)

Now I just use an escape or a ~

There are some caveats using {} in a string literal

     > say "iteration: { ++$ }" xx 5
     (iteration: 1 iteration: 1 iteration: 1 iteration: 1 iteration: 1)
     > my $a; say "iteration: { ++$a }" xx 5
     (iteration: 1 iteration: 2 iteration: 3 iteration: 4 iteration: 5)

That is likely what they were talking about.

Basically these two bits of code are equivelent

     "{$x}::{$y}"

     "" ~ {$x}() ~ "::" ~ {$y}() ~ ""

So I wouldn't use {} if you can just use the variable itself.


Thank you!

Reply via email to