title: What is the ruby equivalent of Go defer?
body: <p>I am a new to Ruby and I am working on a project which involves using this. Go offers the <a href="https://tour.golang.org/flowcontrol/12" rel="noreferrer"><code>defer</code></a> statement, and I wanted to know how I could replicate that function in ruby.</p>
  
  <p>Example:</p>
  
  <pre><code>dst, err := os.Create(dstName)
  if err != nil {
      return
  }
  defer dst.Close()
  </code></pre>