0

Shorthand Assignment Operators

In the Ruby tutorial it says "All of the arithmetic operators have corresponding shorthand forms for assignment. For example, a = a + 8 can be written as a += 8. The same applies to the other operators:" Im stumped, how can a = a + 8? Thats like saying 4 = 4 + 1 like that makes no sense and they dont explain it at all

8/29/2019 2:20:30 AM

Max Rich

2 Answers

New Answer

0

Max Rich I am not into Ruby but this concept is common for c++ also.... in fact in layman terms, you can say that a = a +8 is allowed and 4= 4 + 1 is not allowed.... why because 4 is r value and a is lvalue.... a = a + 8 is not like 4 = 4+1.... a = a + 8 means the way of saying below: a is variable which stores or holds some value... this value should be now incremented by 8... this is what it interprets... in other words, a = 15 for example makes a = 23 post a += 8

0

so how would u write that out in code? the 15 example