You need to sign in to do that
Don't have an account?
If else in APEX
Does whitespace matter between the ELSE and IF keywords? For example are the two code snips below the same logic wise?
if(condition){ } else if(condition){ } else{ }
if(condition){ } else if(condition){ } else{ }
no
Output will be same.
If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.
Thanks
Both are same....
While this has already been answered a few times, perhaps it would be useful to know why. Apex Code, like Java (and C++, C#, etc.) use curly braces to delineate "blocks", such as functions, do-while loops, etc, which also affect "scope" (what data and methods are available in a given line of code), and uses semi-colons to delineate "statements", which are single units of work. Outside of strings, white space may be arbitrarily placed. You could also write your code like this:
or even like this (assuming single-statement blocks):