Is empty return still required in V2? Topic is solved

Get help for the alpha version of AutoHotkey v2 here. Please state the v2 version you are working with in the title when making a new topic.
User avatar
Posts: 106
Joined: 29 Nov 2020, 09:06

Is empty return still required in V2?

Post by Coiler » 06 Dec 2020, 11:20

I noticed in the docs for V2, the page for "return" does not have a return at the end of the hotkey in the example at the bottom of the page. Here's the hot-key code for convenience:

Code: Select all

#z::  ; Win-Z
^#z::  ; Ctrl-Win-Z
    MsgBox "A Win-Z hotkey was pressed."
    if GetKeyState("Ctrl")
        return  ; Finish early, skipping the function call below.
I was wondering if this means that return is no longer required at the end of hotkeys and functions as long as they use scope brackets { }?

I've always had trouble remembering to add empty returns to everything, coming from a C++ background where its not required. I'm also a coder that absolutely has to add comments above every line of code explaining what's happening, and there is absolutely nothing meaningful to comment about an empty return 8-)

Example of one of my functions:

Code: Select all

	; clear tic states after every command (do this BEFORE sending the hot-key, in case the key some how triggers more changes)
	LinkTic := TicNONE

	; send command & return
	Send( com )


	; done

Posts: 4223
Joined: 11 Jan 2017, 17:59

Re: Is empty return still required in V2?  Topic is solved

Post by swagfag » 07 Dec 2020, 03:06

its not required. v2 hotkeys are now entirely based on functions instead of labels. a function whose scope ends implicitly returns an empty string. single line hotkeys implicitly return(same as in v1)

Post Reply

Return to “AutoHotkey v2 Help”