Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Boolean counter?

by ikegami (Pope)
on Dec 07, 2009 at 08:08 UTC ( #811444=note: print w/replies, xml ) Need Help??


in reply to Boolean counter?

For starters,
if ($toggle) { $toggle = 0; } else { $toggle = 1; }

can be written as

$toggle = $toggle ? 0 : 1;

And if you wanted a bitwise toggle, you could do

$toggle ^= 1;

But you asked for boolean, so you want the even simpler:

$toggle = !$toggle;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://811444]
help
Chatterbox?
[stevieb]: It is clear that JetBrains needs an XS plugin. That at this time is WAY beyond my comprehension :)

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2017-02-22 02:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (323 votes). Check out past polls.