Chinna Karuppan wrote: > Hi, > I am trying to under this operator |=.Has anybody got some documentation > / online link to explain this.... > > > > > THnks > Chinna The number 10 written in binary format is: 8's 4's 2's 1's --- --- --- --- 1 0 1 0 The number 11 written in binary format is: 8's 4's 2's 1's --- --- --- --- 1 0 1 1 Assume 1 is equal to true and 0 is equal to false. Now OR each column together: 1 0 1 0 1 0 1 1 OR ---------- <--result? In the first column(the leftmost column) you have (true OR true), which is true, i.e you write 1 for the result: 1 0 1 0 1 0 1 1 OR ---------- 1 <--result? In the second column, you have (false OR false), which is false, i.e you write a 0 for the result: 1 0 1 0 1 0 1 1 OR ---------- 1 0 <--result? In the third column, you have (true OR true), which is true: 1 0 1 0 1 0 1 1 OR ---------- 1 0 1 <--result? In the last column, you have (false OR true) which is true: 1 0 1 0 1 0 1 1 OR ---------- 1 0 1 1 <--result? What number is that? 8's 4's 2's 1's --- --- --- --- 1 0 1 1 1x8 + 0x4 + 1x2 + 1x1 = 11. So 10 | 11 is equal to 11. The syntax a |= b is similar to the syntax a += 1. a += 1 is equivalent to a = a + 1. So a |= b is equivalent to a = a | b. From the above you should now know how to OR two numbers together: convert the numbers to binary format and then OR the columns together. -- Posted via http://www.ruby-forum.com/.