I need check sequence contains another sequence, but based on one field only:
case class Test(f1: Int, f2: String)
val seq = Seq(Test(1, "a"), Test(2, "b"), Test(3, "a"), Test(4, "c"))
Now i want to have something like(theoretical not working code):
seq.containsSlice(Seq(Test(2, _), Test(3, _))) shouldBe true
Where second field can be any.
My idea - create another class, based on Test
, where equals/hashcode
uses only one field, and convert my Seq[Test]
to Seq[TestWithOneField]
. May be there is more elegant and universal solution?