about 1 year ago

a ||= 1;
=> 1
a ||= 2;
=> 1

foo = false;
=> false
foo ||= true;
=> true
foo ||= false;
=> true

当a是nil时,被赋予了b值,但是当赋予了b值后,已经被定义,将不能赋予其他任何值

← find vs find_by helper_method →
 
comments powered by Disqus