title: How do I reduce code duplication with nested 'if' statements?
body: <p>let's consider this code:</p>
  
  <pre><code>let getBuildDate (assembly: Assembly) : DateTime option =
  
      let buildVersionMetadataPrefix = "+build"
      let attribute = assembly.GetCustomAttribute&lt;AssemblyInformationalVersionAttribute&gt;()
  
      if attribute &lt;&gt; null &amp;&amp; attribute.InformationalVersion &lt;&gt; null then
          let value = attribute.InformationalVersion
          let index = value.IndexOf(buildVersionMetadataPrefix)
          if index &gt; 0 then
              let value = value.Substring(index + buildVersionMetadataPrefix.Length)
              let success, timestamp = DateTime.TryParseExact(value, "yyyyMMddHHmmss", CultureInfo.InvariantCulture, DateTimeStyles.None)
              if success then
                  Some timestamp
              else
                  None
          else
              None
      else
          None
  </code></pre>
  
  <p>Is there a way to get rid of all the 'else None' statements to have only one?</p>
  
  <p>On one side, I can imagine that for some people the code is more clear with all the None statements spelled out, but on the other side, coming from the C world, I see it as clutter that reduces readability.</p>
  
  <p>There are many cases where you need a series of conditions to be met and all the failed cases go to one place.</p>
  
  <p>If I have a list of conditions that depend on each others' success, how can I make a concise short exit without duplication.</p>