How can unwanted latches be avoided?

Example: Y is assigned to in only one of the two branches of the if statement         
in an unclocked always block, whereas Z is assigned to in both branches.  By omitting
the assignment to Y in both branches, memory is inferred, and a latch is synthesized. 





By making an assigning to Y in both branches of the if statement in the unclocked always block        
no memory is inferred, and no latch is synthesized.





For signals assigned to in an unclocked always block, it is necessary to assign to them in all
branches of if and case statements to avoid unwanted latches.  For signals assigned to
in a clocked always block, it is not necessary to assign to them in all branches of if and case
statements.