Any downsides to using continue within a ternary Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Any downsides to using continue within a ternary

04 Aug 2021, 12:50

I was told that in languages like c you cannot use continue within a ternary. In AHK you can and I would like to know if there is a reason to avoid it?

I created a small example, in this script I really would want to use the ternary operator to save a lot of lines but also dont want to mess things up if the use of continue within this has some downside I do not know.

Code: Select all

ep := 0
array := ["car", "food", "sky"]
for i, v in array
	(v = "food") ? continue : ep+=100
MsgBox, % ep
ExitApp
teadrinker
Posts: 4325
Joined: 29 Mar 2015, 09:41
Contact:

Re: Any downsides to using continue within a ternary  Topic is solved

04 Aug 2021, 13:09

IMO, the downside is that you can lose the clarity of your code. In your case you can change it like this:

Code: Select all

ep := 0
array := ["car", "food", "sky"]
for i, v in array
   (v != "food" && ep += 100)
MsgBox, % ep
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Any downsides to using continue within a ternary

04 Aug 2021, 13:36

u cant use continue in expressions. what u have is the name of a blank variable
AHKStudent
Posts: 1472
Joined: 05 May 2018, 12:23

Re: Any downsides to using continue within a ternary

04 Aug 2021, 14:08

swagfag wrote:
04 Aug 2021, 13:36
u cant use continue in expressions. what u have is the name of a blank variable
:lol: :lol: I feel like a giant idiot, AHK is so tolerant that it fooled me good

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 221 guests