title: How to prevent a failable initializer of a Swift enum from returning nil within a range of raw numbers?
body: <p>I implemented an enum to represent 256 colors of a color map like this:</p>
  
  <pre><code>enum MapColor:UInt8
  {
      case black = 0
      case white = 1
      case red = 2
      case lightRed = 3
      case orange = 7
      ...
      case rampBlue = 78
      ...
      case rampRed = 255
  }
  </code></pre>
  
  <p>However, I have NOT given a case for each color in the color map. I only added specific cases for the most important colors that I want to specify by name, like green, orange, red, yellow, gray, lightYellow, etc. This allows me to specify a color like this:</p>
  
  <pre><code>let color = MapColor.orange
  </code></pre>
  
  <p>without worrying about what is the underlying raw value. At the same time it would allow me to have 256 colors that could be used in gradients in my game. This is why between 78 and 255 I specified in my color map a gradient of colors that goes from blue (rampBlue) and ends in red (rampRed).</p>
  
  <p>However, I wanted to implement a random color generator that returned a raw value between 0 and 255, the possible color gamut for my color map, like this:</p>
  
  <pre><code>func fillColor() -&gt; MapColor
  {
      return MapColor(rawValue: UInt8(abs(Utilities.random(maximum: 255))))!
  }
  </code></pre>
  
  <p>However, obviously, that causes a segmentation fault whenever it tries to initialize the MapColor object with a raw value with a non-existent case.</p>
  
  <p>So my question is: is there any way to avoid this without tediously add all possible cases between 0 and 255 by hand and still keep some explicit cases that I want to refer to by name, but at the same time have the possibility of generating a random color with a value between 0 and 255?</p>