是什么?运算符表示如下语句:
public int IntProperty => (booTrue ? 1 : 0) | (fooTrue ? 2 : 0);
我熟悉=>和?但我从未见过|这样使用。
答案 0 :(得分:1)
它是bitwise or。如果我们查看您代码中的值,您可能会:
Array
(
[0] => Array
(
[id] => 1
[name] => p1
[children] => Array
(
[0] => Array
(
[id] => 1
[parent_id] => 1
[name] => c1
)
[1] => Array
(
[id] => 2
[parent_id] => 1
[name] => c2
)
)
)
[0] => Array
(
[id] => 2
[name] => p2
[children] => Array
(
[0] => Array
(
[id] => 1
[parent_id] => 2
[name] => c3
)
)
)
)
00
01
因此,如果10
为true并且booTrue
为true,它将为fooTrue
。由于是按位运算,所以它是1 | 2
=> 01 | 10
(十进制=> 3)。