This question already has an answer here:
Let's say we have two ifs that depend on each other:
if var exists {
if var is array {
//Do stuff with var
} else {
//Resolve the problem
}
} else {
//Resolve the problem in the exact same way as above
}
//Continue execution with the assumption that var is in the appropriate state
How can I refactor this to remove the duplicated code without using gotos or functions/methods?
goto
of course! – svidgen Aug 7 '14 at 3:09if var exists && var is array
– immibis Aug 7 '14 at 5:37