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は、次のようNumericになります。
$x
Numeric
$x.zero? ? 1 : $x
それは同じだ
x == 0 ? 1 : x
||=0 は「偽の」値ではないため、ここではショートカットは適用できませんtrue。
||=
true