Re: "if" revealed?

webmasterbeta

New Member
Thanks Eric for the help, now for him or any others who want to chime in...Let's try and make this REAL clear...First let us make this code easier to read.1. String insert = $ClientLogo;2. If ("$ClientLogo".equals(insert)){3. a=b==d||e?f:g;4. }else if{5. {a=c;6. }Next, If I were to rewrite this code to make the precedence easier to follow,would it look like this?1. String insert = $ClientLogo;2. If ("$ClientLogo".equals(insert)){3. a=((b==d)||(e?f:g));4. }else if{5. {a=c;6. }Is this correct? Am I understanding the order of operations here?If the order is correct then I believe this is what is happening.First (b==d) is evaluated.Second (e?f:g) is evaluated.Third ((b==d)||(e?f:g)) is evaluated.Fourth a=((b==d)||(e?f:g)) is evaluated.Thanks for your patience. If I can get this part of the code figured outI think I am almost home.Mark"Eric L" <[email protected]> wrote:>>>5 if ("$ClientLogo".equals(insert)) {>>6 replacement = null==logoPicName || "".equals(logoPicName.trim()) ? ">" : "<IMG SRC=http://forums.devx.com/archive/index.php/\"" + logoPicName + "\" ALIGN=center>";>>>Ugly code, but I'll give it a shot.>>First, replacement is a String variable, and it is being assigned the HTML>tag of the logoPicName.>>The ? operator is definatly being used. || is the short-circuit-or operator.> logoPicName is also a String variable.>>So, if logoPicName==null, or logoPicName has not been set to a string, or>>".equals(logoPicName.trim()). "" indicates an empty string. String.trim>removes all leading and trailing spaces in a string. This line checks to>see if there is anything in the logoPicName variable.>>So, as far as I can understand it, this if statement checks to see if logoPicName>is null, or an empty string, and sets Replacement to " " if true else set>Replacement to the <IMG SCR> tag.>>This is my best guess. It is ugly code for a beginner to look at.>>Eric
 
Back
Top