Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Vacuous truth
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== In computer programming == Many programming environments have a mechanism for querying if every item in a collection of items satisfies some predicate. It is common for such a query to always evaluate as true for an empty collection. For example: * In [[JavaScript]], the [[array]] method <code>every</code> executes a provided callback function once for each element present in the array, only stopping (if and when) it finds an element where the callback function returns false. Notably, calling the <code>every</code> method on an empty array will return true for any condition.<ref>{{Cite web|url=https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every|title=Array.prototype.every() - JavaScript | MDN|website=developer.mozilla.org|date=27 November 2023 }}</ref> * In [[Python (Programming Language)|Python]], the built in <code>all()</code> function returns <code>True</code> only when all of the elements of an array are <code>True</code> or the array is of length zero as shown in these examples: <code>all([1,1])==True; all([1,1,0])==False; all([])==True</code>.<ref>{{cite web |title=Built-in Functions β Python 3.10.2 documentation |url=https://docs.python.org/3/library/functions.html#all |website=docs.python.org}}</ref> A less ambiguous way to express this is to say <code>all()</code> returns True when '''none of the elements are False'''. * In [[Rust (programming language)|Rust]], the <code>Iterator::all</code> function accepts an iterator and a predicate and returns <code>true</code> only when the predicate returns <code>true</code> for all items produced by the iterator, or if the iterator produces no items.<ref>{{Cite web|url=https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.all|title=Iterator in std::iter β Rust|website=doc.rust-lang.org}}</ref> * In SQL, the function, the function <code>ANY_VALUE</code> can differ depending on the RDBMS's behaviour relating [[Null (SQL)|NULLs]] to vacuous truth. Some RDBMS might return <code>null</code> even if there are non-<code>null</code> values.<ref>{{Cite web |title=The ANY_VALUE(β¦) Aggregate Function |url=https://modern-sql.com/caniuse/any_value |access-date=2024-11-27 |website=modern-sql.com |language=en}}</ref> Some DBMS might not allow for its use in <code>filter(β¦)</code> or <code>over(β¦)</code> clauses. * In [[Kotlin (programming language)|Kotlin]], the collection method <code>all</code> returns <code>true</code> when the collection is empty. * In [[C Sharp (programming language)|C#]], the Linq method <code>All</code> returns <code>true</code> when the collection is empty. * In [[C++]], the <code>std::all_of</code> function template returns <code>true</code> for an empty collection.<ref>{{Cite web |date=19 March 2024 |title=std::all_of, std::any_of, std::none_of |url=https://en.cppreference.com/w/cpp/algorithm/all_any_none_of |url-status=live |archive-url=https://web.archive.org/web/20241201074645/https://en.cppreference.com/w/cpp/algorithm/all_any_none_of |archive-date=1 December 2024 |access-date=9 December 2024 |website=Cpprefeference}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)