4

I was just wondering if anyone could think of a single word meaning the opposite of contains.

E.g.

  • This bottle of beer contains alcohol whereas this one doesn't.

  • This bottle of beer doesn't contain alcohol whereas this one does.

Basically, I'm looking for a single word which means doesn't contain.

2
  • 2
    Programmers try to avoid negative verbs in function names. The logic is something like this: NotContains implies two operations: 1) checking whether the object contains something, and 2) a boolean "not". If the caller needs to negate it, he will. IsEnabled is preferred to IsDisabled, and IsValid is preferred to IsInvalid as well. There are exceptions where the negative function name is fundamentally relevant to the operation, like IsBlacklisted. I would suggest you just stick with Contains().
    – tenfour
    Mar 25, 2011 at 15:58
  • 1
    Why has this question turned into a stackoverflow.com -esque one? Jul 4, 2017 at 13:35

10 Answers 10

3

With regards to the programming context mentioned elsewhere, you can use terms such as "absent" or "missing" as in:

Assert.Absent( ... )

Assert.Missing( ... )

These seem highly likely to confuse whoever needs to read your code next, however, since no one will be searching for these terms. Contains is an extremely well adopted term for checking containers for objects. NotContains (from one of your comments) will at least match a query for "Contains".

In short: The terms exist but I wouldn't use them.

1
  • 1
    Thanks. I've actually gone with: IsContained and NotContained which to me seems to be slightly better grammar.
    – Nick
    Mar 25, 2011 at 15:35
15

I think "lacks" is the word you seek.

This beer lacks alcohol.

2
  • or else 'is free from' Jul 4, 2017 at 13:05
  • Perversely (referring to the language), 'lacks' often means 'needs / could do with'. A deficiency, not just an absence. Jan 2 at 16:16
11

In some contexts, exclude might work: “the price excludes postage”. In general, no, I can't think of a single word meaning “does not contain”.

4

Here are my suggestions:

  • This bottle of beer is devoid of alcohol.
  • This bottle of beer is alcohol-free.
1

Synonym.com offers no antonyms for 'contains'.

Even if you could find some esoteric term, what use would if be if so few could understand it? Besides, what is wrong with 'does not contain'?

5
  • Thanks for your answer. It's actually for a function name in a computer program. I have a Contains( ) function and I wanted a simple opposite rather than DoesntContain( ).
    – Nick
    Mar 25, 2011 at 11:20
  • 4
    @Nick: How about !Contains()? Am I missing something? (^_^)
    – RegDwigнt
    Mar 25, 2011 at 11:31
  • A bit more context. It's an assertion checker so I have the functions: Assert.Contains( ... ) and Assert.NotContains( ... ) to check whether a container contains an item.
    – Nick
    Mar 25, 2011 at 11:58
  • 1
    'NotContains' is my preference in that context. Clumsy English, but the meaning will be clear to any other developer.
    – CJM
    Mar 25, 2011 at 13:59
  • 2
    @CLM As an other developer, that would not be clear to me mainly because it's an unusual English construct. !Contains() would work for me, or for Nick's purposes reformulating as Assert.IsTrue(!myCollection.Contains(...));
    – Ed Guiness
    Mar 25, 2011 at 14:04
1

Empty

Is the word often used when a container does not contain anything (the container is empty)

Contains() is a strange name for a function that returns a boolean (true or false), it could be short for containsSomething, or containsNothing and is therefore a little ambigous.

Edit:

In that case you might want to try isMissing or omitted

2
  • Thanks for your answer. I suppose I should have expanded it. It actually takes a container and a value returning true if the container contains the value. I.e. Contains( ICollection container, Object value );
    – Nick
    Mar 25, 2011 at 15:17
  • In that case Missing or Omitted might work okay (have updated my answer)
    – Tom
    Mar 25, 2011 at 15:38
1

Void

This beer contains alcohol, this other beer is void of alcohol.

1

How about:

  • lacks
  • excludes
  • omits
  • doesNotContain
  • or !contains, !includes, etc.

The last two suggestions are for code variable names, assuming that follows the guidelines of this exchange.

0
0

Using a count() function and testing for zero:

bottle.count("alcohol") == 0

versus

bottle.notContains("alcohol")

It is not only shorter (by one character) while producing a more general result, but also avoids boilerplate at the start of the function name which has to be typed before your editor can begin offering sensible choices.

You will say of course that counting all the alcohol molecules in a bottle to find out if it contains just one such molecule is rather a waste of time, but this means that you lack faith in your compiler to detect this optimization opportunity for you.

Conversely, if you possess a device that can individuate a single molecule of alcohol then it is time to give up programming and switch to extracting gold from seawater.

5
  • 2
    Welcome to English Language and Usage! I notice you have not completed the tour, which states that 'English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts.' Your answer centers around coding, which is more appropriate for stackoverflow.com. Please keep it language-related! Jul 4, 2017 at 13:38
  • 1
    This is a Programming answer, posted on an English site. In the early days of this site this sort of thing was tolerated, as it was a spinoff of a programming website, but these days this site is very language focussed. Your answer is hence not suitable today.
    – AndyT
    Jul 4, 2017 at 13:40
  • Language, surely, without context is meaningless. Programming is a legitimate use of language, so why not discuss the use of language in this specific context? Alternatively, what language contexts would you permit to be discussed on this web site? Why are your choices better?
    – bbb bbb
    Jul 4, 2017 at 15:10
  • Are we to suppose that programmers have no need to use the the English language in a "serious" or "enthusiastic" manner and should therefore be banned from discussing the application of English to their work?
    – bbb bbb
    Jul 4, 2017 at 15:14
  • ... there is no desire to ban the discussion of programming, and of course many will use English as well as computer language. Just like there is no desire to ban the discussion of the French language. But there are dedicated SE sites for each of these ... and also one for what one would expect to meet in an English language course in the Sixth Form in the UK, at college, etc. Jan 2 at 16:22
0

Please consider "contains no" as in:

bottle.containsNo("alcohol")

as it is a common feature of diglossic languages to make new words by combining shorter words as in "football" or "television". I would mention the benefits of moving the boiler plate to the back if that were permissible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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