조건에 대입 사용 경고
이 경고 범주의 철자는 [assignment-in-condition] 입니다.
조건에 대입 사용에 대한 경고
무슨 일이 일어났나요?
if-condition 안에 대입을 사용했습니다.
이것이 왜 나쁜가요?
이것은 종종 실수이며 비교를 사용했어야 합니다. 의도적인 경우라도 혼동을 주는 경우가 많습니다.
예시
import QtQuick Item { id: root Component.onCompleted: { // mistake: should have been a comparison if (width = height) console.log("A square") let mypoint = Qt.point(1,2) let hit = false // intentional, but possibly misleading if (hit = root.contains(myPoint)) console.log("hit") root.enabled = hit } }
이 경고를 수정하려면 실수인 경우 과제를 비교로 변경하세요. 그렇지 않으면 대입이 의도적으로 이루어졌음을 나타내기 위해 대입을 괄호로 묶습니다.
import QtQuick Item { id: root Component.onCompleted: { // fixed if (width === height) console.log("A square") let mypoint = Qt.point(1,2) let hit = false // intentional if ((hit = root.contains(point))) console.log("hit") root.enabled = hit } }
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.