Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    What does the ? mean in this line of code

    I'm trying to decipher the meaning in this code. The ? is confusing me.

    HighPage = (CurrentCoursePage > HighPage) ? CurrentCoursePage : HighPage;

    Any help would be greatly appreciated!

  • #2
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    It's using the ternary operator (google it).
    This:
    Code:
    HighPage = (CurrentCoursePage > HighPage) ? CurrentCoursePage : HighPage;
    Means:
    If the CurrentCoursePage is greater than the HighPage then HighPage = CurrentCoursePage else HighPage = HighPage.

    It's a short way of saying:
    Code:
    if(CurrentCoursePage > HighPage)
    {
       HighPage = CurrentCoursePage;
    }
    else
    {
       HighPage = HighPage;
    }
    Good luck;

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    could be used also like this:
    condition?statement(or function):statement(or function);

    and could be used without else{}
    condition?statement(or function):null;
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •