Hardcoding Expectations

One of the strangest things I had to get used when I started programming in Erlang was to write correct programs (compared to programs that handled all cases). This is one of the fundamental rules in Erlang.

If you look at the code from Nested Cases, you can see through inspection that the function can return one of two possible values: null or {ok,Value}

Note lines 5 and 9. This is in principle very bad code. Keep in mind that you expect the multiply operation to actually return {ok,Value}, the rest doesn't mean anything. In reality you are now forcing the code calling this function to understand details about deeply nested functions. Because you *know* that the multiply funtion will succeed (It is one of your assumptions), it is much better to write: