Jump to content

Recommended Posts

Posted

I asked myself some questions, and I have some thoughts.

 
Well, I was wondering whether or Ternary operators can be nested?
 
Here is an example:
For $x = 0 To 1
    For $y = 0 To 1
        $r = ($y = 0) ? (($x = 1) ? (True) : (False)) : (False)
        ConsoleWrite('$x=' & $x & ' $y=' & $y & '' & ' $r=' & $r & @CRLF)
    Next
Next

 

The answer is Yes.
>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /beta /ErrorStdOut /in "L:\TEST Ternary.au3" /UserParams
+>22:33:46 Starting AutoIt3Wrapper v.2.1.4.2 SciTE v.3.3.7.0 ; Keyboard:00000415 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0415 Keyboard:00000415 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)
>Running AU3Check (3.3.11.2) from:C:\Program Files (x86)\AutoIt3\Beta
+>22:33:46 AU3Check ended.rc:0
>Running:(3.3.11.2):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "L:\TEST Ternary.au3"
--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
$x=0 $y=0 $r=False
$x=0 $y=1 $r=False
$x=1 $y=0 $r=True
$x=1 $y=1 $r=False
+>22:33:47 AutoIt3.exe ended.rc:0
>Exit code: 0 Time: 0.972

I hope that this will clarify the other members of the case.

 
 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

You might want to mark this as solved.

See first post.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted
  On 1/5/2014 at 9:40 PM, DatMCEyeBall said:

You should mark this topic as solved.

  On 1/5/2014 at 9:41 PM, guinness said:

You might want to mark this as solved.

See first post.

'tis but a minor coincidence.

"Just be fred, all we gotta do, just be fred."  -Vocaliod

"That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha

@tabhooked

Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation

Posted (edited)

  On 1/5/2014 at 9:44 PM, DatMCEyeBall said:

'tis but a minor coincidence.

No it is. I saw your post in the Call() vs First Class Object thread after posting that.

I agree that nested ternary operators could get a little confusing. It took me 20 seconds to confirm the output was indeed correct. Good job the loop wasn't 30!

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...