0

I'm programming and want to create a variable only if it does not already exist.

Is there a way to express this with a single word?

For example, if the variable already exists, I have the options

  • overwrite to overwrite the current value with a new value
  • append to append new data to existing data

I'm searching for the word to express if the data already exists, leave it alone, otherwise take the given data.

  • 1
    In database terms this is called an 'insert or update' – Mitch Oct 8 '15 at 15:05
  • This is a common scenario, but to my knowledge there is no single term that covers most of the possible situations. The closest, perhaps, is "singleton", but it only applies to a narrow range of problems (and, as a programming concept, it stinks). – Hot Licks Oct 9 '15 at 11:12
1

Merge is what you are looking for, at least in the SQL lexicon.

It is also called an Upsert, which indicates data can be updated where it exists and inserted where it does not.

This does not necessarily mean that existing data will be updated; existing data can be left as is.

Boring technical link

  • @eckes My initial answer was incomplete. Edited. – Eric Hauenstein Oct 8 '15 at 16:00
1

perhaps you want to ensure existence of the variable?

-1

If you do not want to update the entry, but simply insert it if it does not already exist, perhaps the term could be "ifsert" :)

New contributor
kevin is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • No one would understand this word, and most would assume it's a typo for "insert". – Chappo yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.