What does ||= do in Ruby

ruby

Solution

This will assign `bar` to `foo` if (and only if) `foo` is `nil` or `false`.

EDIT: or false, thanks @mopoke.

Problem

I've been using Ruby for a while now, and I keep seeing this: ``` foo ||= bar ``` What is it?

Original source

Related problems