True that
-
A friend of mine wrote this little pearl a while ago. When I took the keyboard and wrote "true", we laughed for a good 5 mins. ...the next step was getting rid of the crazy infinite loop.
while(Convert.ToBoolean(1))
{
// do stuff
} -
A friend of mine wrote this little pearl a while ago. When I took the keyboard and wrote "true", we laughed for a good 5 mins. ...the next step was getting rid of the crazy infinite loop.
while(Convert.ToBoolean(1))
{
// do stuff
} -
Why?
Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D
-
Why?
Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D
while(true) isn't self-documenting
while(true)
{
.... lots of code
if(drunk) break;
drinkBeer();
.... lots more code
}I much prefer
while(!drunk)
{
.... lots of code
drunk = true;
if(drunk) continue;drinkBeer();
.... lots more code
}Although its probably just the drink beer bit I really like :)
"You get that on the big jobs."
-
while(true) isn't self-documenting
while(true)
{
.... lots of code
if(drunk) break;
drinkBeer();
.... lots more code
}I much prefer
while(!drunk)
{
.... lots of code
drunk = true;
if(drunk) continue;drinkBeer();
.... lots more code
}Although its probably just the drink beer bit I really like :)
"You get that on the big jobs."
RobCroll wrote:
while(true) isn't self-documenting
Guess that's where comments comes in handy.
RobCroll wrote:
while(true)
{
.... lots of code
if(drunk) break;
drinkBeer();
.... lots more code
}I much prefer
while(!drunk)
{
.... lots of code
drunk = true;
if(drunk) continue;
drinkBeer();
.... lots more code
}I'm a fan of
while(true)
but the first is simply garbage, I never used it like that.Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D
-
RobCroll wrote:
while(true) isn't self-documenting
Guess that's where comments comes in handy.
RobCroll wrote:
while(true)
{
.... lots of code
if(drunk) break;
drinkBeer();
.... lots more code
}I much prefer
while(!drunk)
{
.... lots of code
drunk = true;
if(drunk) continue;
drinkBeer();
.... lots more code
}I'm a fan of
while(true)
but the first is simply garbage, I never used it like that.Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D
-
You've got my interested now. So how do you use
while(true)
without coding garbage like break; (or return)?"You get that on the big jobs."
No, no, don't misunderstand me. I use break;, continue;(above loop) or return; It's the context that I disagree with (ie. if you can make it simple with just a boolean, why do you need a while(true)?).
Oxfords English < Official CCC Players Dictionary Excuse me for my improper grammar and typos. It's because English is my primary language, not my first language. My first languages are C# and Java. VB, ASP, JS, PHP and SQL are my second language. Indonesian came as my third language. My fourth language? I'm still creating it, I'll let you know when it's done! :-D
-
A friend of mine wrote this little pearl a while ago. When I took the keyboard and wrote "true", we laughed for a good 5 mins. ...the next step was getting rid of the crazy infinite loop.
while(Convert.ToBoolean(1))
{
// do stuff
}I actually have a LOT of While 1=1 in MS SQL... It's very cool, works great, and I just love to see the face of programmers when I show them with pride my nested while 1=1 loops in recursive stored procs... ;P