miscon:programming.booleans.must-compare-with-literal · draft · trust low · v0.1.1 · kind undergeneralization
A boolean must be compared with true to be used as a condition
A boolean variable or expression cannot be used directly as a condition; it has to be compared with true or false first, and a comparison is the only thing that produces a condition.
- Stable URI
- https://open-misconceptions.github.io/miscon-data/m/programming.booleans.must-compare-with-literal
- UUID
1e4090f5-0d1e-4bf3-af12-7671e11aaf09- Domain
programming.boolean- Level band
- secondary, undergraduate
- Locale
- en
- About
- https://open-misconceptions.github.io/miscon-data/c/programming.booleans.expression (Miscon)
Evidence patterns
Pattern 0: write a condition from a boolean variable
writes == true (or == True) and cannot explain what if done: alone would do
done is a boolean. Write the condition for 'if done'.if done:if done == True:The == True form runs correctly, so this is only diagnosable by asking, or from a follow-up item.
Pattern 1: return a boolean from a comparison
wraps the comparison in if/else returning literal true and false
Return whether n is even.return n % 2 == 0if n % 2 == 0:
return True
else:
return FalseDiscriminators
vs a slip. A slip is a stylistic habit the learner can drop when asked. The belief is the claim that if done: is invalid or that a comparison is not a value.
Relations
conflicts_with- A boolean expression is itself a value (external)
resolved_by- A boolean expression is itself a value (external)
Alignments
- progmiscon Java/ComparisonWithBooleanLiteral (close-match)
- progmiscon Python/ComparisonWithBoolLiteral (close-match)
- progmiscon Python/MapToBooleanWithIf (close-match)
Provenance
Origin: llm-drafted
- Chiodini, L., Moreno Santos, I., Gallidabino, A., Tafliovich, A., Santos, A. L., & Hauswirth, M. (2021). A curated inventory of programming language misconceptions. In Proceedings of the 26th ACM Conference on Innovation and Technology in Computer Science Education (ITiCSE '21), 380-386. doi:10.1145/3430665.3456343
Inventory consulted for the misconception name and scope only; progmiscon publishes no licence for its text, so Open Misconceptions' statements and examples are written independently.
Drafted from the cited literature for the Open Misconceptions seed pack; statement, examples and discriminators are original text. Awaiting maintainer review.
Review status
Status draft, trust low (computed from the reviews below against the reviewer registry).
No reviews yet.
Formats
- Raw JSON
- CASE 1.1 package (CFItem
1e4090f5-0d1e-4bf3-af12-7671e11aaf09) - Source on GitHub
Cite
miscon:programming.booleans.must-compare-with-literal
https://open-misconceptions.github.io/miscon-data/m/programming.booleans.must-compare-with-literal