Results 1 to 8 of 8
  1. #1
    diggitydoggz is offline Member
    Join Date
    Dec 2008
    Posts
    55
    Rep Power
    0

    Default what does this line of code mean?

    Hey all, been reading through a pretty advanced java game development book. I came across a line of code and I'm unable to figure out what it means (it's the syntax and the question mark confusing me, not really the commands):

    Here it is:

    Java Code:
    isOverPauseButton = pauseArea.contains(x, y) ? true : false;
    Could anyone explain to me what that means?

    Thanks.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    A similar question was asked yesterday. Have a look:
    Shorthand ?

  3. #3
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default

    This explains it:

    Shorthand ?

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default The fastest post in the west...

    Dang it Furball... you always do that !!! Well, on the bright side, we seem to be on the same frecuency :)

    Take care,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  5. #5
    diggitydoggz is offline Member
    Join Date
    Dec 2008
    Posts
    55
    Rep Power
    0

    Default

    Thanks guys. I'll have a look.

  6. #6
    diggitydoggz is offline Member
    Join Date
    Dec 2008
    Posts
    55
    Rep Power
    0

    Default

    Interesting... it would seem that in my example above the whole ternary operator isn't even necessary (since it's testing the .contains for true or false, it might as well just say:

    Java Code:
    isOverPauseButton = pauseArea.contains(x, y);
    right?)

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by CJSLMAN View Post
    Dang it Furball... you always do that !!! Well, on the bright side, we seem to be on the same frecuency :)Take care,CJSL
    LOL. I'm wearing my ninja suit today. Que tenga un buen da!

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. line feed in CSV
    By javaplus in forum New To Java
    Replies: 2
    Last Post: 01-24-2008, 03:46 PM
  2. What does this line of code mean?
    By naxalyte in forum New To Java
    Replies: 1
    Last Post: 11-23-2007, 09:28 PM
  3. Reading in data from file line by line
    By bluekswing in forum New To Java
    Replies: 1
    Last Post: 10-02-2007, 12:19 AM
  4. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

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