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.
对您来说很简单:PHP 中的 Ruby 等价物是什么?
return $x == 0 ? 1 : $x;
如果你知道那$x是 a Numeric,那么:
$x
Numeric
$x.zero? ? 1 : $x
一样的
x == 0 ? 1 : x
快捷方式在||=这里不适用,因为 0 不是“假”值,它是true.
||=
true