Code:Runnable[] runnables = {() -> handleHigh()}; try { runnables[Math.min(0, index - 10)].run(); } catch(Exception e) { handleLow(); }
|
|





Sounds like the kind of guy that spends half of the day overthinking simple solutions.

interestingly all of the solutions so far are way worse than using a simple if statement, so if the senior devs intention was to demonstrate their clear superiority they did a good iob

100% agree
this thread is nonsense, either ur senior dev is stupid or u didn't understand his point properly, but avoiding conditional checks for a performance gain, which in most cases (see OP's self called 'excellent solution' code for example) will only make things worse

I think Harry is probably on the mark about his senior dev wanting him to be mindful of design patterns rather than just passing everything off in mindless control flow statements, but idk why anyone would have an inherent dislike for if statements, they're just simple control branching and as we see here the alternatives are usually shit.

Believe the thread was more about coming up with interesting ways to avoid an if-statement rather than coming up with better / more elegant solutions (because we're all aware that it's easier to just do a conditional branch).
| « Wanting to get into rsps coding | [Request] Need osrs models + animations for a hobby project » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |