You are here: Re: coding tip to prevent comparisons becoming assignments « PHP Programming Language « IT news, forums, messages
Re: coding tip to prevent comparisons becoming assignments

Posted by Peter Fox on 03/22/06 11:30

Following on from Oli Filth's message. . .
>Peter Fox said the following on 21/03/2006 09:22:
>>
>> Here is a precis of my standard lecture (shortly to be a book) on equals.
>>
>>
>> The use of = and == is *full* of traps
>>
>> $totalCake = 100;
>> $slices = 7;
>> $slice = $totalCake / $slices;
>> $cakeLeft = $totalCake;
>> while ($cakeLeft != 0){ // will this loop terminate? Always?
>> $cakeLeft = $cakeLeft - $slice;
>> }
>> // Crumbs!!
>
>
>How does that demonstrate the pitfalls of = and == ?
>
>
The same way as "In tonight's programme we'll talk to Hugh Jampton,
captain of Britain's five-a-side archery team *and* later visit the new
indoor hang gliding centre at Little Bagworth. But first here are the
results of today's Woolworth's League (division 2) downhill crochet
matches."

Hope that explains the use of "and".


--
PETER FOX Not the same since the adhesive company came unstuck
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация