- #1
techmologist
- 306
- 12
I was recently writing a function to return the quotient of two Big Numbers, in which there were several if/else conditionals. Instead of having one return statement at the very end, I intended to have a separate return statement for each conditional block (this might be bad style, i don't know). Only I forgot to put a return statement in one of them. The weird thing is, the code still more or less worked--though not quite as expected--even when control flow entered that faulty block. Does the compiler somehow know to insert some default return value when it does not find a return statement where it is expected?
In this case, it returned the value of the same variable whose value I had returned in the previous block.
In this case, it returned the value of the same variable whose value I had returned in the previous block.