in reply to Two simple code style advice questions

It strikes me that, as a pattern, 2b works for all values of True, while 2a does not.

TJD

  • Comment on Re: Two simple code style advice questions

Replies are listed 'Best First'.
Re^2: Two simple code style advice questions
by Anonymous Monk on Jan 16, 2013 at 14:07 UTC

    It strikes me that, as a pattern, 2b works for all values of True, while 2a does not.

    What does that mean?

    I think they both work for all values of true, even if it isn't clear what you mean by that

      It probably means "Using '... x condition' is not always safe":
      say $_ ? "true" : "false", "a" x $_ for 0, 1, "0e0";
      لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
        Now what do you mean by that? What is it that you expect and how is it unsafe?
      While choroba's example is elegantly expresses what I was getting at, I'd also like to point out other True values, like 3, 5 or, more entertainingly, MAXINT. >;^)

        Well, repeat operator repeats a number of times, its repeat operator, if you want to repeat at most once, force !!boolean