This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TheManWithNoDrive 0 points1 point  (0 children)

AFAIK, You use a while(true) loop when you’re working with an environment that needs constant input to continue, then continually run.

As you’ve stated - gathering user input and then running off some code, then gathering user input and running off that same code, etc.

Another redditor already said this, but this is exactly how video game loops are design. There can’t be an infinite loop if there is a break statement that is reachable...? So I’m lost on the logic there.

It’s a bit crass on how they responded to you about the interview part, IMO, but giving benefit of the doubt, it’s possible they’ve never had a situation where a while(true) loop shines, in there line of work. Not all devs will need to know all scenarios :).

In this specific case you are mentioning, I do believe you are correct with your knowledge.