Skip to main content
Code Review

Return to Answer

Removed the UPDATE text. it wasn't really needed anynmore
Source Link
Malachi
  • 29k
  • 11
  • 86
  • 188

UPDATE

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment and this Answer

UPDATE

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment and this Answer

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment and this Answer

deleted old stuff that wasn't needed
Source Link
Malachi
  • 29k
  • 11
  • 86
  • 188

UPDATE

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment and this Answer


OLD

I was thinking about a new answer and this just came to me.

I assume that you only want to update when newValue has something in it and you only want to delete when currentValue has something in it, so why don't you do something like this:

boolean updateRequired = (newValue != null)
boolean deleteRequired = (currentValue != null)

which would actually lead me to change it so that if you have something that needs to happen if one or the other is true then you would write it out like this

if (updateRequired || deleteRequired) {
 //play Galaga
 //do some stuff
}

UPDATE

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment and this Answer


OLD

I was thinking about a new answer and this just came to me.

I assume that you only want to update when newValue has something in it and you only want to delete when currentValue has something in it, so why don't you do something like this:

boolean updateRequired = (newValue != null)
boolean deleteRequired = (currentValue != null)

which would actually lead me to change it so that if you have something that needs to happen if one or the other is true then you would write it out like this

if (updateRequired || deleteRequired) {
 //play Galaga
 //do some stuff
}

UPDATE

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment and this Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

UPDATE

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment Comment and this Answer Answer


OLD

I was thinking about a new answer and this just came to me.

I assume that you only want to update when newValue has something in it and you only want to delete when currentValue has something in it, so why don't you do something like this:

boolean updateRequired = (newValue != null)
boolean deleteRequired = (currentValue != null)

which would actually lead me to change it so that if you have something that needs to happen if one or the other is true then you would write it out like this

if (updateRequired || deleteRequired) {
 //play Galaga
 //do some stuff
}

UPDATE

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment and this Answer


OLD

I was thinking about a new answer and this just came to me.

I assume that you only want to update when newValue has something in it and you only want to delete when currentValue has something in it, so why don't you do something like this:

boolean updateRequired = (newValue != null)
boolean deleteRequired = (currentValue != null)

which would actually lead me to change it so that if you have something that needs to happen if one or the other is true then you would write it out like this

if (updateRequired || deleteRequired) {
 //play Galaga
 //do some stuff
}

UPDATE

I think I know what you are looking for. you only want to do stuff if

  • x = false and y = true
  • x = true and y = false

and not when

  • x = false and y = false
  • x = true and y = true

in that case I would think that what you want is an XOR or an Exclusive Or

boolean isNewValueAssigned = newvalue != null;
boolean isCurrentValueAssigned = currentValue != null;
if (isNewValueAssigned ^ isCurrentValueAssigned) {
 //Play more Galaga
 //do More Work
}

I think that this makes it more clear what you are trying to do.

Reference to this Comment and this Answer


OLD

I was thinking about a new answer and this just came to me.

I assume that you only want to update when newValue has something in it and you only want to delete when currentValue has something in it, so why don't you do something like this:

boolean updateRequired = (newValue != null)
boolean deleteRequired = (currentValue != null)

which would actually lead me to change it so that if you have something that needs to happen if one or the other is true then you would write it out like this

if (updateRequired || deleteRequired) {
 //play Galaga
 //do some stuff
}

added 84 characters in body
Source Link
Malachi
  • 29k
  • 11
  • 86
  • 188
Loading
added 139 characters in body
Source Link
Malachi
  • 29k
  • 11
  • 86
  • 188
Loading
added 371 characters in body
Source Link
Malachi
  • 29k
  • 11
  • 86
  • 188
Loading
Source Link
Malachi
  • 29k
  • 11
  • 86
  • 188
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /