• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

assignment operator?

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I read a book it stated that once b1 set to false by assignment operator the remaining will be false but why on line 2 i still can go to the other test?
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by ming ming:

I read a book it stated that once b1 set to false by assignment operator the remaining will be false but why on line 2 i still can go to the other test?



In the second line your condition is (b1=false) | (b1=true). This is a boolean or operator. It requires that both conditions be evaluated. An or is true is either of its operands are true. Since in the second condition you set b1 to true, the result of the or is true.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you read about the conditional-AND (&&) and conditional-OR (||) operators from the book. Only Conditional-AND, Conditional-OR and Conditional-Assignment (? will evaluate the operands based on need (if further evaulation is needed to determinte the outcome).

The operators you mentioned in this snippet are Logical/Bitwise OR operator which evaluates all the operands before performing the operation.
 
ming ming
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but what happened in line 1?
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
((b1=false)|(b1&b3)|(b1|b2))
1a. ((false)|(false&true)|(false|false))
1b. ((false)|(false)|(false))
The result is false.
 
reply
    Bookmark Topic Watch Topic
  • New Topic