Mythruna
May 16, 2024, 01:38:04 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the new forums. See "Announcements" for a note for new users.
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: Finals!  (Read 10771 times)
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #15 on: December 14, 2012, 11:10:11 PM »

In C/C++, this is another good one:

Code:
if (z=1) {
    // do stuff
}

Wow im tired took me 2 passes to see it

It's possible to let the compiler detect it with full warnings on sometimes.  Java specifically disallows this sort of thing since boolean expressions must be of type boolean.  But it's bad for a few reasons because a) the if will always succeed and b) it will corrupt the value of z at the same time.
Logged
Iggyjeckel
Donators
Hero Member
***
Posts: 510


View Profile
« Reply #16 on: December 14, 2012, 11:36:43 PM »

yeah after i looked at it a second time i did the face palm thing and went...yup done that my before in my first semester lol
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!