Posted by Oli Filth on 03/21/06 12:42
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 == ?
--
Oli
Navigation:
[Reply to this message]
|