Help with some terms

Discussion in 'Public Game Developers Forum' started by kohjingyu, Jun 14, 2009.

  1. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Hey guys,
    Can anyone explain to me when to use = and when to use ==? And what is the difference?

    Also, can anyone tell me what is SQLite3?
     
  2. Spotlight

    Spotlight Well-Known Member

    Jan 10, 2009
    536
    0
    0
    1 = 1
    1 = 1 = 1

    SQLite3: http://en.wikipedia.org/wiki/SQLite
     
  3. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    I mean like what's the difference between something = something and something == something.
     
  4. rdklein

    rdklein Well-Known Member

    Apr 3, 2009
    384
    0
    0
    sw developer, tv producer, hw developer (microcodi
    Munich
    = is an assignment
    == is a comparison.
    You need to take a tutorial on C++ / C also Java is using the same an other languages,
    while Delphi, Pascal, Modula2 uses := for assignment and = to compare values.
     
  5. cool mr croc

    cool mr croc Active Member

    May 27, 2009
    41
    0
    0
    int x=2;
    if(x==2)
    //do something

    thats the correct way to use it, x is assigned the value of 2, then x is asked if its equal to 2, then returns a true value which runs whats in the if block.

    had you done

    int x==2;

    nothing would have happened, (really this statement returns a false boolean but its not used for anything)

    had you done

    if(x=2)
    //do something

    x would have been assigned 2, the if condition would have been met and whatever is in its block would run everytime.
     
  6. shodanng

    shodanng Well-Known Member

    Apr 2, 2009
    294
    0
    0
    If you don't know the difference between = and ==, you should study basic C syntax before you try to develop a app.
     
  7. You use = when you want to assign a variable a value.

    Hence,

    x = 2 <--now the variable 'x' has the value of 2

    You use == when you want to compare two values to see if they are the same.

    Hence,

    x = 2;
    y = 2;

    x == y; <-- this is TRUE

    y = 3;

    x == y; <-- this is FALSE (x still has a value of 2 since we didn't change the value)


    SQLite is the best database tool for iPhone developers. You may want to use it if your app will be dealing with a lot of information.
     
  8. kohjingyu

    kohjingyu Well-Known Member

    Mar 20, 2009
    1,770
    0
    0
    Student/Developer
    Singapore
    Thanks guys! :)
     
  9. M of IMAK

    M of IMAK Well-Known Member

    May 26, 2009
    199
    0
    0
    iPhone App Developer
    Austin, TX
    If you use SQLite, you will also want to check out Jeff LeMarche's SQLite Persistent Objects, which you can read about on his blog.

    If you don't use SQLite, or don't want to, or want to be on the leading edge, then you should read up on Core Data.

    Also, to introduce some Cocoa syntax, to compare two NSNumber objects, you can use:

    Code:
    BOOL isEqual = [myFirstNumber isEqualToNumber:mySecondNumber];
     

Share This Page