FAQ: Difference between revisions

Jump to navigation Jump to search
4 bytes added ,  27 January 2014
m
Line 364: Line 364:
===Increment and decrement operators===
===Increment and decrement operators===


If you like the {{Codeline|++}}, {{Codeline|+=}} etc operators, rejoice! Octave includes the C-like increment and decrement operators {{Codeline|++}} and {{Codeline|--}} in both their prefix and postfix forms, in addition to {{Codeline|+-}}, {{Codeline|-=}}, {{Codeline|*=}}, {{Codeline|/=}}, {{Codeline|^=}}, {{Codeline|.*=}}, {{Codeline|./=}}, and {{Codeline|.^=}}.
If you like the {{Codeline|++}}, {{Codeline|+=}} etc operators, rejoice! Octave includes the C-like increment and decrement operators {{Codeline|++}} and {{Codeline|--}} in both their prefix and postfix forms, in addition to {{Codeline|+=}}, {{Codeline|-=}}, {{Codeline|*=}}, {{Codeline|/=}}, {{Codeline|^=}}, {{Codeline|.*=}}, {{Codeline|./=}}, and {{Codeline|.^=}}.


For example, to pre-increment the variable x, you would write {{Codeline|++x}}. This would add one to x and then return the new value of x as the result of the expression. It is exactly the same as the expression {{Codeline|x = x + 1}}.
For example, to pre-increment the variable x, you would write {{Codeline|++x}}. This would add one to x and then return the new value of x as the result of the expression. It is exactly the same as the expression {{Codeline|x = x + 1}}.

Navigation menu