What word means to make something true if it is at first false?

What is the word in programming that means that checks a condition for true or false, and if the condition is false, code is run to make that condition true, so that if the condition is checked again, it would be true?

I believe I have seen something in Swift or Foundations that does this as applied to different things.

yourVariable = true

You are talking about NOT
With a Swift Bool, you can use toggle()

The two specific words that spring to mind are negate and complement. In most programming languages this task is done with the NOT operator. In Swift that operator is !. For example:

let t = true
print(!t)
// prints: false

toggle() is a mutating method on Bool:

var b = true
b.toggle()
print(b)
// prints: false

It’s basically equivalent to:

b = !b

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

The best I've come up with is "assure", "insure", and especially "constraint". "Force" is a good one too. I settled with . . .

checkAndResave(_:completionHandler:)

I was looking for a really accurate word to name a function that checks to see if a certain datum has been saved in a data store, then if it hasn't then I save it. So the word I'm looking for needs to reflect that I make sure it's there. Maybe "verify", but that still doesn't convey that I save the data if it's not there, just to check to be sure that it is there with the expectation that it is there. I take the presumption that I don't know whether it's there or not.

That's fine. I'll settle with "checkAndResave".

Thank you everyone.

Maybe a word will pop up in the middle of the night while I'm half asleep.

How about you flip the name around so the primary behavior (saving) comes before the secondary (checking): saveIfNeeded() or saveIfDirty(). Or build in a little more flexibility to disable the checking, such as for testing:

func save(onlyIfDirty: Bool = true, completionHandler: SaveCompletionHandler)
func save(onlyIfDirty: Bool = true) async throws
What word means to make something true if it is at first false?
 
 
Q