A
A
Aleksandr Govorukhin2016-02-22 22:55:26
iOS
Aleksandr Govorukhin, 2016-02-22 22:55:26

What is the correct way to write *= in Swift 2?

Hello!
A very stupid question, but still:
Why, for example, the entry:

result = 10
result *= 2 + 1

gives the answer 30 and not 21? Isn't it the same as result = result * 2 + 1? If not, please explain how to correctly write the abbreviated version.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Zhukov, 2016-02-22
@SnapSh0t

The order of operators is the same in almost all languages. 30 is the correct result
There are also += -= /= etc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question