Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 ruby 中,|=运算符是做什么的?
|=
例子:
a = 23 a |= 3333 # => 3351
单个竖线是按位或运算符。
a |= 3333相当于a = a | 3333
a |= 3333
a = a | 3333
|=被称为语法糖。
在 Rubya = a | 3333中与a |= 3333.
|方法
|
如果二进制或运算符存在于任一操作数中,则复制一个位。Ruby 位运算符