작성
·
254
답변 1
0
안녕하세요.
결론부터 이야기 하면 =+ , + 연산자는 내부적으로 다르게 작동합니다.
방대한 내용이고 다른 언어와 병행해서 학습 하다보면 자연스럽게 공통점과 차이점을 알게되는 부분입니다.
아래 링크를 올려드릴께여. 번역해서 한 번 읽어보세요.
https://stackoverflow.com/questions/41446833/what-is-the-difference-between-i-i-1-and-i-1-in-a-for-loop
An augmented assignment expression like
x += 1
can be rewritten asx = x + 1
to achieve a similar, but not exactly equal effect. In the augmented version, x is only evaluated once. Also, when possible, the actual operation is performed in-place, meaning that rather than creating a new object and assigning that to the target, the old object is modified instead.이렇게 나와있는 걸 보니, a *=2를 했을 때는 하나의 리스트에 append처럼 값을 더 넣는 것 같고 a = a * 2는 리스트 두 개를 합쳐서 새로운 리스트를 변수에 할당하는 것으로 이해했는데 혹시 맞을까요?.?