Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Two simple code style advice questions

by Anonymous Monk
on Jan 16, 2013 at 13:48 UTC ( #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
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
Node Status?
node history
Node Type: note [id://1013573]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (10)
As of 2014-12-22 15:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (119 votes), past polls