What does ||= (or-equals) mean in Ruby?

前端 未结 23 2880
情书的邮戳
情书的邮戳 2020-11-21 23:20

What does the following code mean in Ruby?

||=

Does it have any meaning or reason for the syntax?

23条回答
  •  你的背包
    2020-11-21 23:41

    This ruby-lang syntax. The correct answer is to check the ruby-lang documentation. All other explanations obfuscate.

    Google

    "ruby-lang docs Abbreviated Assignment".

    Ruby-lang docs

    https://docs.ruby-lang.org/en/2.4.0/syntax/assignment_rdoc.html#label-Abbreviated+Assignment

提交回复
热议问题