Ruby idiom a | |= b meaning?

What does the ruby idiom a ||= b mean?

Thanks,
Ratnavel

Ratnavel P S wrote:

What does the ruby idiom a ||= b mean?

Thanks,
Ratnavel

If a is not set (or is nil), set it with the value of b.

Thanks Ryan,

On Jul 1, 2008, at 12:34 AM, Ratnavel P S wrote:

What does the ruby idiom a ||= b mean?

Thanks,
Ratnavel

It is like:
a || a = b
See David A. Black’s Blog
http://dablog.rubypal.com/2008/3/25/a-short-circuit-edge-case

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs