I have the following code from the Coursera course Functional Program Design in Scala. It is supposed to be a generator of maps of Int to Int.
lazy val genMap: Gen[Map[Int, Int]] = for {
k <- arbitrary[Int]
v <- arbitrary[Int]
m <- oneOf(const(Map.empty[Int, Int]), genMap)
} yield m.updated(k, v)
My problem is I don't know how to use it. Typing:
genMap.generate
does not work. So how can I get maps from Int to Int from this generator?
Aucun commentaire:
Enregistrer un commentaire