Hacker News new | past | comments | ask | show | jobs | submit login

Sure. Create a type that represents x being <= that threshold, with a private constructor. Only allow constructing it via a factory method that requires it to be an x that should be <= the threshold. Then whenever you have a value of that type, you know that it's legitimately <= the threshold, and the bug becomes impossible.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: