Ask HN: What are the best programming tricks you know?

During my studies, I was surprised that even a variable swap might be optimized to work in place by using XOR. Since then, I got surprised at least a few times more. For example when I was working a lot with SQL and found some engine-specific optimizations. What were the simplest, or the most clever neat tricks you faced in […]