Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Two simple code style advice questions

by Anonymous Monk
on Jan 16, 2013 at 13:48 UTC ( [id://1013573]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1013573]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-04-19 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found