Using scalactic, one can convert an Every
to a List
like this:
scala> Every(1,2,3).toList
res6: List[Int] = List(1, 2, 3)
How can I perform the reverse operation, though, i.e. try to convert a List
or an Iterable
to an Every
? Is there a built-in method that does this?
Simply:
val everyOpt: Option[Every[Int]] = Every.from(List(1, 2, 3))
If the list is known to be non empty:
val every: Every[Int] = Every.from(List(1, 2, 3)).get