Question Marks Floating Around in Code -- Please Explain - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Question Marks Floating Around in Code -- Please Explain

JediGeek709JediGeek709 Posts: 11Member
I was looking at some borrowed code today and saw a few lines that looked similar to this:

[code]this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];[/code]

But I have never heard of the ? operator. Could someone please try to explain why that '?' is floating around in there?

Comments

  • JonathanJonathan Posts: 2,914Member
    : I was looking at some borrowed code today and saw a few lines that looked similar to this:
    :
    : [code]this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];[/code]
    :
    : But I have never heard of the ? operator. Could someone please try to explain why that '?' is floating around in there?
    :
    It's a short form of "if (a) b else c", but written "a ? b : c". For example:-

    a = 2 > 1 ? 1 : 0; /* a is 1 (as condition is true) */
    a = 1 > 2 ? 1 : 0; /* a is 0 (as condition is false) */

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.