0

I am creating property based tests for my scala project but I don't know how I should handle Eithers in my generators. Here's an example.

def genCompany: Gen[Company] =
    for {
      letter <- Gen.oneOf('A' to 'Z')
      company = Company.from(letter.toString()) //-> returns Either[Error, Company]
    } yield company

Should I change the return type to Gen[Either[Error, Company]]? If so, how would I use this generator inside other generators?

Thank you very much!

to.mane
  • 13
  • 3
  • Use `company = Company(letter.toString)` instead. `<-` in `company <- ...` is a shorthand or syntactic sugar for map method. [Read more](https://docs.scala-lang.org/tour/for-comprehensions.html) – AminMal May 21 '22 at 09:47
  • Thank you so much! I was getting that error right now and couldn't figure out why! – to.mane May 21 '22 at 09:48

0 Answers0