You know it's time to 'take 5' when...

Caporegime
Joined
18 Oct 2002
Posts
29,493
Location
Back in East London
You spend 45mins scratching your head at a simple loop that won't stop looping..

Code:
//snippet..
public function getFile ()
{	
	if ((isset($this->files[$this->filesIndex])) !== false) {
		return $this->files[$this->filesIndex];
	} else {
		$this->filesIndex = 0;
		return FALSE;
	}
}
should be..
Code:
public function getFile ()
{	
	if ((isset($this->files[$this->filesIndex])) !== false) {
		return $this->files[$this->filesIndex++];
	} else {
		$this->filesIndex = 0;
		return FALSE;
	}
}

Code:
//use in..

while (($file = $dir->getFile()) !== false) {
//blah..
}
:(

What's your indication that you need to go take a breather?

EDIT: fs.. add one more on my list: 'You have to edit a post 5 or 6 times to get it right..' :(
 
Last edited:
Act of habit has me checking types. I'm very 'particular' about my challenges I guess :)

Either it's that or it's because I have one or two that require I check type which has me wanting to make all of them look the same :p
 
the only real reason I want to get into it, is because it's almost the most common requirement I am seeing on job-specs :(
 
Dammit.. why did I ever get into programming? It gives me grief at every corner.. a colleague for a project, just sent me his bits and bobs for one of the modules.. I open it to check out the method names and see this at the top of most of the pages..:
Code:
if ($_POST) { //this type of if() just makes me weep..
doSomethingWith($_POST['var']); //straight into functionality without explicitly checking for indice
}
(obviously not like-for-like)

ARGH!
 
Back
Top Bottom