Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (2)

Sign In or Sign Up now to post a comment!
  • this may sound basic, but if i have statements:

    i = j = k = 42;

    and:

    a + b + c + d;

    How do i apply the associativity rule? As in, do i start reading from the start or the back of the statement and then when i hit the first operator i start bracketting...

  • '=' is right to left associative, and that's the natural way to think about it. The right hand side is fully evaluated before the assignment can be made to the left hand side. That means you have:

    i = ( j = k = 42);

    Now look inside the brackets and apply the rule again.

    i = ( j = (k = 42));

    Addition is left to right associative. So it would mean (((a + b) + c) + d); By the way that's not a statement its an expression.

  • thank you so much.

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more