<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Does the OR operator in Arcade test short-circuit evaluation as it does in javascript? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366213#M6884</link>
    <description>&lt;P&gt;In Javascript the logical OR expression is evaluated left to right, it is tested for possible "short-circuit" evaluation using the following rule:&lt;/P&gt;&lt;P&gt;(some truthy expression) || expr is short-circuit evaluated to the truthy expression.&lt;/P&gt;&lt;P&gt;Short circuit means that the expr part above is not evaluated, hence any side effects of doing so do not take effect (e.g., if expr is a function call, the calling never takes place). This happens because the value of the operator is already determined after the evaluation of the first operand.&lt;/P&gt;&lt;P&gt;Does Arcade behave in the same way?&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jan 2024 11:49:34 GMT</pubDate>
    <dc:creator>JamesNightingale</dc:creator>
    <dc:date>2024-01-04T11:49:34Z</dc:date>
    <item>
      <title>Does the OR operator in Arcade test short-circuit evaluation as it does in javascript?</title>
      <link>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366213#M6884</link>
      <description>&lt;P&gt;In Javascript the logical OR expression is evaluated left to right, it is tested for possible "short-circuit" evaluation using the following rule:&lt;/P&gt;&lt;P&gt;(some truthy expression) || expr is short-circuit evaluated to the truthy expression.&lt;/P&gt;&lt;P&gt;Short circuit means that the expr part above is not evaluated, hence any side effects of doing so do not take effect (e.g., if expr is a function call, the calling never takes place). This happens because the value of the operator is already determined after the evaluation of the first operand.&lt;/P&gt;&lt;P&gt;Does Arcade behave in the same way?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 11:49:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366213#M6884</guid>
      <dc:creator>JamesNightingale</dc:creator>
      <dc:date>2024-01-04T11:49:34Z</dc:date>
    </item>
    <item>
      <title>Re: Does the OR operator in Arcade test short-circuit evaluation as it does in javascript?</title>
      <link>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366354#M6885</link>
      <description>&lt;P&gt;It doesn't look like you can have an expression that is a function call, even if it does return a boolean. For example, running this code gives the error "Test execution error: Execution error - Logical expression can only be combined with || or &amp;amp;&amp;amp;. Verify test data."&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function first() {
  console('First');
  return true;
}

function second() {
  console('Second');
  return true;
}

return first||second;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 16:45:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366354#M6885</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-01-04T16:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Does the OR operator in Arcade test short-circuit evaluation as it does in javascript?</title>
      <link>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366362#M6886</link>
      <description>&lt;P&gt;Hi KenBuja,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your response. Although that is interesting, it's not what I'm trying to find out - what I want to know is whether the Arcade OR operator tests short-circuit evaluation of the two expressions. Ignore the example of the function calls and instead replace them with:&lt;/P&gt;&lt;P&gt;If ((some truthy expression) || (some other expression) {&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Would the second 'some other expression' get evaluated? In JS or C# it doesn't since the || operator short-circuits due to the first expression being truthy and therefore the second expression doesn't need to be evaluated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 16:55:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366362#M6886</guid>
      <dc:creator>JamesNightingale</dc:creator>
      <dc:date>2024-01-04T16:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Does the OR operator in Arcade test short-circuit evaluation as it does in javascript?</title>
      <link>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366378#M6887</link>
      <description>&lt;P&gt;It turns out my code was incorrect, since the function calls need parenthesis behind them. When I fixed it, it does short-circuit.&lt;/P&gt;&lt;P&gt;If the first function is false, then the second function runs&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="console1.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90532iCAE0B689CF1E60EF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="console1.png" alt="console1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If the first function is true, the second function doesn't run&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="console2.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/90533iCBEEF415F83B18D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="console2.png" alt="console2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 17:19:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/does-the-or-operator-in-arcade-test-short-circuit/m-p/1366378#M6887</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-01-04T17:19:24Z</dc:date>
    </item>
  </channel>
</rss>

