Re:Ask HN: Can someone explain why this line exists?
by zaroth on Thursday May 30, 2013 @12:46AM
(#5790977)
Upvote to you, and downvote to whoever wrote that line of code.
A ternary inside an 'if' statement, really? And even more so when one of the return values is 'true'?
Relax, it's just a bug, right? But it would be nice if programmers practiced basic Boolean reduction in their 'if' statements...
(!((_ok) ? true : (Math.random() > 0.1)))
!((_ok) ? true : (Math.random() > 0.1))
_ok ? false : !(Math.random() > 0.1)
!_ok && Math.random() <= 0.1
Wait, what?