InstructionWhich7142
Registered User.
- Local time
- Today, 10:38
- Joined
- Feb 24, 2010
- Messages
- 203
My old functions were serious pyramid code, often multiple nested if's deep, since then I've been using guard clauses and setting values/checking values though a series of separate if's instead of nesting, it's definitely easier to keep track of the "end" compared to nesting!
However I'm stuck when it comes to loops as there's no "continue" function to "exit sub" from that loop based on the guard clause, I suppose I could call the function repeatedly instead of it being a loop, but that wouldn't work for a nested loop that's relying on values from the main function, I know they could be passed but that's back to getting harder to read and jumping around more than "goto SkipLoop" would be?
I'm not bothered either way about goto or not goto, but the convention is there for a reason and I'm curious to have other opinions on best practice
However I'm stuck when it comes to loops as there's no "continue" function to "exit sub" from that loop based on the guard clause, I suppose I could call the function repeatedly instead of it being a loop, but that wouldn't work for a nested loop that's relying on values from the main function, I know they could be passed but that's back to getting harder to read and jumping around more than "goto SkipLoop" would be?
I'm not bothered either way about goto or not goto, but the convention is there for a reason and I'm curious to have other opinions on best practice