while browsing some source code i noticed a weird operator being used on a while loop
topLoop: while(dist < 0){
random code...
}
what does the 'topLoop:' mean in this situation? and what does it do to the while exactly? p.s. topLoop is just a int defined earlier on in the code.
The colon is not an operator. The topLoop: is called a label. You can use it, for example, to directly jump from a nested loop to outside the outer loop.
There's probably a break topLoop; statement somewhere inside the loop that you didn't show. This will make execution jump to the topLoop label.
Labels are used only seldomly in practice, and in my opinion using labels is bad practice - they are a kind of goto statement, and using them can quickly make your code a hard to understand, tangled mess.
p.s. topLoop is just a int defined earlier on in the code.
Maybe the code has a variable named topLoop, but this has nothing to do with the label that happens to have the same name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With