What is use of ||= begin....end block in Ruby?
<p>What is the difference between these snippets?</p>
<pre class="lang-ruby prettyprint-override"><code>def config
  @config ||= begin
                if config_exists?
                  @config = return some value
                else
                  {}
                end
              end
end
 
</code></pre>
<pre class="lang-ruby prettyprint-override"><code>def config
  @config ||= method
end

def method
  if config_exists?
    return some value
  else
    {}
  end
end
</code></pre>
<p>I'm confused with the &quot;<code>begin</code> ... <code>end</code>&quot; block. Does it make any difference in the output? If not, then what is the use of the <code>begin</code> ... <code>end</code> block here?</p>