Made my day

Discussion in 'iOS Development' started by Ezekeel, May 16, 2009.

Thread Status:
Not open for further replies.
  1. Ezekeel

    Ezekeel New Member

    Joined:
    Mar 15, 2009
    Messages:
    771
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
  2. wibble

    wibble New Member

    Joined:
    Mar 16, 2008
    Messages:
    176
    Likes Received:
    0
    eww spaghetti
  3. bamhm182

    bamhm182 Member

    Joined:
    Mar 2, 2009
    Messages:
    544
    Likes Received:
    0
    Device:
    3G iPod touch
    Sorry to sound like a complete idiot, but I am new to programming, so I've got a question. What's the difference between == and =? I've seen this come up in multiple apps I've been building from this book, but it hasn't mentioned it. It was also brought up the thread you linked to, so what's the difference? Thanks in advance.
  4. Pelaez-1

    Pelaez-1 New Member

    Joined:
    May 5, 2008
    Messages:
    822
    Likes Received:
    0
    Device:
    iPhone
    == is to check if two objects are the same, and = assigns a value.

    Examples

    Code:
    int a = 4, b = 5;
    
    if(a==b)
    //something that won't happen because 4 isn't the same as 5
    
    b = a; //b will now be 4
    
    if(a==b)
    //something that WILL happen because now b is 4 too, and 4 is equal to 4
  5. bamhm182

    bamhm182 Member

    Joined:
    Mar 2, 2009
    Messages:
    544
    Likes Received:
    0
    Device:
    3G iPod touch
    Alright, cool, makes complete sense now, thanks.

    Please Register or Log in to view images



    So when you get something like (toOrientation == UIInterfaceOrientationLandscapeLeft)(I think that's all correct, just going off the top of my head though, so forgive me if there's an error) than it's checking to make sure that the value "toOrientation" is equal to "UIInterfaceOrientationLandscapeLeft"? Meaning that when you've got your iPod in Landscape Left, than it sets everything associated with toOrientation to know that it's in Landscape Left.

    If that's correct, I've completely got it. If not, I'm over-complicating things, but still completely understand it.
  6. oioioi

    oioioi New Member

    Joined:
    Apr 18, 2008
    Messages:
    102
    Likes Received:
    0
    Just remember to not use = in if statement
    Code:
    if(x = 10)
    {
    //x is now 10 and the code in this scope will always run
    }
  7. Ezekeel

    Ezekeel New Member

    Joined:
    Mar 15, 2009
    Messages:
    771
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Yeah and no formatting and bad choices for variable names and using a static 10x10 matrix when a matrix of dynamic size is required and unnecessary system() calls and no idea of matrix calculus and ....

    This is by far the worst C/C++ code I have ever seen. Guys like this are the reason not everyone should be allowed to own a compiler.
  8. jamil_d

    jamil_d Active Member

    Joined:
    Dec 15, 2007
    Messages:
    2,041
    Likes Received:
    12
    Device:
    iPhone 3GS (Black)
    Whoa. That code is really, really unorganized. When people don't indent or use whitespace properly, I get really annoyed for some reason. I hate unorganized code.

    ex.
    Code:
    cout<<"\nEnter The Matrix you want to Transpose: "; cin>>T;
    Should be
    Code:
    cout<<"\nEnter The Matrix you want to Transpose: ";
    cin>>T;
    And spaces after the commas in multiple variable declarations! Please!
  9. Pelaez-1

    Pelaez-1 New Member

    Joined:
    May 5, 2008
    Messages:
    822
    Likes Received:
    0
    Device:
    iPhone
    Not to mention a lot of "if"s instead of "switch", and "goto"s instead of a well thought "while"
  10. Ezekeel

    Ezekeel New Member

    Joined:
    Mar 15, 2009
    Messages:
    771
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Yeah you could make this into a game to count all the logic errors and also occurrences of a bad programming style.
Thread Status:
Not open for further replies.

Share This Page