title: Creating random string to represent RGB color
body: <p>Suppose I need to generate random string to represent an RGB color. The string consists of <code>#</code> and 6 hex digits: e.g. <code>#ff0000</code> or<code>#cafe00</code>.</p>
  
  <p>I am doing it with <a href="https://github.com/DanielaSfregola/random-data-generator" rel="nofollow noreferrer">random data generator</a> like that:</p>
  
  <pre><code>import com.danielasfregola.randomdatagenerator.RandomDataGenerator._
  import org.scalacheck.{Arbitrary, Gen}
  
  def randomRGB(): String = {
  
    implicit val arbitraryString: Arbitrary[String] = Arbitrary {
      for {
        r &lt;- Gen.choose(0, 255)
        g &lt;- Gen.choose(0, 255)
        b &lt;- Gen.choose(0, 255)
      } yield "#" + r.toHexString + g.toHexString + b.toHexString
    }
  
    random[String]
  }
  </code></pre>
  
  <p>How would you improve it ?</p>