조건에서 할당 사용에 대한 경고
이 경고 카테고리의 철자는 [warn-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 } }
© 2025 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.