Ambiguous condition in if statement Get link Facebook X Pinterest Email Other Apps By Admin - January 19, 2011 if ( x == 0 ) if ( 0 == x) consider both the cases what is potential bug in first statement and how second statement is better? Get link Facebook X Pinterest Email Other Apps Comments AdminJanuary 19, 2011 at 12:45 PMpotential bug in first statement...if ( x == 0 ) // if we forget and make it single =, it becomes x = 0, and the bug is severe that cant be found so easily unless we have eagle eyes :)so second statement is better.ReplyDeleteRepliesReplyAdminJanuary 19, 2011 at 1:03 PM@B Ramesh yeah very true and if we make it single = in second statement it will give error.(invalid lvalue in assisgment).ReplyDeleteRepliesReplyAdd commentLoad more... Post a Comment
potential bug in first statement...
ReplyDeleteif ( x == 0 ) // if we forget and make it single =, it becomes x = 0, and the bug is severe that cant be found so easily unless we have eagle eyes :)
so second statement is better.
@B Ramesh yeah very true and if we make it single = in second statement it will give error.(invalid lvalue in assisgment).
ReplyDelete