You are reading a single comment by @DavidM_ and its replies.
Click here to read the full conversation.
-
Sadly no -
collectFirst
takes a partial function (in this casePartialFunction[(Instruction, Int), Int]
) which I can't wrangle theinput
collection into. It's a bit of a 'square peg round hole' situation. I should probably craft something myself for such a case.In your code snippet the case would be satisfied on the first instruction and I would then get a
NoSuchElementException
.
Not really au-fait with Scala but I would have thought you could pattern-match on the result of
swapAndExecute
? Almost certainly not correct syntax, but something like