If statement in Mockito examples

What is inferred latch and how it is created when it is missing else statement in if condition. Can anybody explain briefly?

A latch is inferred when the output of combinatorial logic has undefined states, that is it must hold its previous value.

Combinatorial logic does not have any flip-flop to hold state therefore the output should always be defined by the inputs.

A short example might be:

What is when. is not being overridden so it would hold its value. How can something hold its value when it does not have the concept of state. You have to introduce state by inferring a latch. This is normally a really bad thing.

You can imply latches and be carefull about the timing etc but inferred latches are nominally from buggy code.

answered Mar 17 '14 at 18:19
18.4k66 gold badges5454 silver badges7878 bronze badges