• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Operators =

 
Swerrgy Smith
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In the book of Kathy and Bert, there is a piece of code that I don't understand.



Could any one explain why when we test (b = true) then the line "b is is true" is printed. But when we change to (b = false) then the line "b is false" is printed???


Thank you.
 
Seema Kekre
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
b= true is not just a test but an assignment, b is being assigned a new value true and then it is tested for if. If it was b==true that would have been just a test
 
Diana Sule
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, for booleans the if will test the value of the assingment.
 
Swerrgy Smith
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK I see how it works Thank you very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic