<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://miniscript.org/w/index.php?action=history&amp;feed=atom&amp;title=Comparison</id>
	<title>Comparison - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://miniscript.org/w/index.php?action=history&amp;feed=atom&amp;title=Comparison"/>
	<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=Comparison&amp;action=history"/>
	<updated>2026-05-13T09:57:16Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>http://miniscript.org/w/index.php?title=Comparison&amp;diff=1156&amp;oldid=prev</id>
		<title>Marc Gurevitx: /* Equality */</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=Comparison&amp;diff=1156&amp;oldid=prev"/>
		<updated>2023-11-22T15:10:36Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Equality&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 15:10, 22 November 2023&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Equality ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Equality ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The operator &amp;lt;c&amp;gt;==&amp;lt;/c&amp;gt; tests for equality; the operator &amp;lt;c&amp;gt;!=&amp;lt;/c&amp;gt; is the negation of equality. These operators always result in [[true]] or [[false]]. Both can be applied to ''any'' values, not necessarily of the same type. If the values have different types, they're considered not equal. Otherwise, they're compared according to their types:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The operator &amp;lt;c&amp;gt;==&amp;lt;/c&amp;gt; tests for equality; the operator &amp;lt;c&amp;gt;!=&amp;lt;/c&amp;gt; is the negation of equality. These operators always result in [[true]] or [[false]] &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;(or in some cases of incompatible types - &amp;lt;c&amp;gt;null&amp;lt;/c&amp;gt;)&lt;/ins&gt;. Both can be applied to ''any'' values, not necessarily of the same type. If the values have different types, they're considered not equal. Otherwise, they're compared according to their types:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[null]] is equal to itself&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* [[null]] is equal to itself&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Marc Gurevitx</name></author>
		
	</entry>
	<entry>
		<id>http://miniscript.org/w/index.php?title=Comparison&amp;diff=1146&amp;oldid=prev</id>
		<title>Marc Gurevitx: Details on comparison</title>
		<link rel="alternate" type="text/html" href="http://miniscript.org/w/index.php?title=Comparison&amp;diff=1146&amp;oldid=prev"/>
		<updated>2023-11-17T16:10:39Z</updated>

		<summary type="html">&lt;p&gt;Details on comparison&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Comparison operators: &amp;lt;c&amp;gt; == &amp;lt;/c&amp;gt;, &amp;lt;c&amp;gt; != &amp;lt;/c&amp;gt;, &amp;lt;c&amp;gt; &amp;gt; &amp;lt;/c&amp;gt;, &amp;lt;c&amp;gt; &amp;lt; &amp;lt;/c&amp;gt;, &amp;lt;c&amp;gt; &amp;gt;= &amp;lt;/c&amp;gt;, &amp;lt;c&amp;gt; &amp;lt;= &amp;lt;/c&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Equality ==&lt;br /&gt;
&lt;br /&gt;
The operator &amp;lt;c&amp;gt;==&amp;lt;/c&amp;gt; tests for equality; the operator &amp;lt;c&amp;gt;!=&amp;lt;/c&amp;gt; is the negation of equality. These operators always result in [[true]] or [[false]]. Both can be applied to ''any'' values, not necessarily of the same type. If the values have different types, they're considered not equal. Otherwise, they're compared according to their types:&lt;br /&gt;
&lt;br /&gt;
* [[null]] is equal to itself&lt;br /&gt;
* [[number]]s and [[string]]s are compared in the usual way. (Unlike in some other languages, &amp;lt;c&amp;gt;0 == &amp;quot;0&amp;quot;&amp;lt;/c&amp;gt; is false.)&lt;br /&gt;
* [[list]]s are equal if they contain equal elements&lt;br /&gt;
* [[map]]s are equal if they contain equal key/value pairs&lt;br /&gt;
* [[funcRef]]s are equal if they reference the same function&lt;br /&gt;
* The special value [[NaN]] is not equal to anything, even to itself&lt;br /&gt;
&lt;br /&gt;
To compare [[list]]s and [[map]]s by reference, use [[refEquals]] function.&lt;br /&gt;
&lt;br /&gt;
== Relational operators ==&lt;br /&gt;
&lt;br /&gt;
Comparisons &amp;lt;c&amp;gt; &amp;gt; &amp;lt;/c&amp;gt;, &amp;lt;c&amp;gt; &amp;lt; &amp;lt;/c&amp;gt;, &amp;lt;c&amp;gt; &amp;gt;= &amp;lt;/c&amp;gt;, &amp;lt;c&amp;gt; &amp;lt;= &amp;lt;/c&amp;gt; are defined for numbers (arithmetic comparison) and strings (alphabetic comparison). These cases result in [[true]] or [[false]].&lt;br /&gt;
&lt;br /&gt;
For other data types or for operands of different data types they return [[null]].&lt;br /&gt;
&lt;br /&gt;
If the operands are a number and a [[null]], they substitute [[null]] with &amp;lt;c&amp;gt;0&amp;lt;/c&amp;gt; (resulting in [[true]] or [[false]]).&lt;br /&gt;
&lt;br /&gt;
If the operands are a string and a [[null]], it considers the string being always greater than [[null]] (resulting in [[true]] or [[false]]).&lt;br /&gt;
&lt;br /&gt;
All six operators support [[Operators#Comparison_Operators|chaining]].&lt;br /&gt;
&lt;br /&gt;
=== Examples ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ms&amp;gt;&lt;br /&gt;
print null == null      // prints 1&lt;br /&gt;
print 0 != &amp;quot;0&amp;quot;          // prints 1&lt;br /&gt;
print 13 &amp;lt; 42 &amp;lt;= 420    // prints 1&lt;br /&gt;
print 2 &amp;lt; 15            // prints 1&lt;br /&gt;
print &amp;quot;2&amp;quot; &amp;lt; &amp;quot;15&amp;quot;        // prints 0, alphabetic comparison&lt;br /&gt;
print 0/0 == 0/0        // prints 0, NaN != NaN&lt;br /&gt;
print [1, 2, 3] == [1, 2, 3]    // prints 1&lt;br /&gt;
print 0 != null and 0 &amp;gt;= null and 0 &amp;lt;= null  // prints 1 :)&lt;br /&gt;
&amp;lt;/ms&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Language]]&lt;/div&gt;</summary>
		<author><name>Marc Gurevitx</name></author>
		
	</entry>
</feed>