Kotlin Programming Cookbook
上QQ阅读APP看书,第一时间看更新

Or

The or function compares the corresponding bits of two values. If either of the two bits is 1, it gives 1, and it gives 0 if not.

Consider this example:

fun main(args: Array<String>) {
val a=2
val b=3
print(a or b)
}

The following is the output:

 3

Here's the explanation of the preceding example:

2 = 10 (Binary format)

3 = 11 (Binary format)

 Bitwise OR of 2 and 3 that is

in binary 

 10 OR 11

 11 = 3 (Decimal format)