Questions about writing code

Get help with using AutoHotkey and its commands and hotkeys
afe
Posts: 618
Joined: 06 Dec 2018, 04:36

Questions about writing code

25 May 2020, 03:34

Which of the following three codes is more conducive to reading or which one is recommended?

Code: Select all

f()
{
   if ( x = 0 )
   {
     y := 1
     return, y
   }
   else
   {
     MsgBox Error
     ExitApp
   }
}

Code: Select all

f()
{
   if ( x = 0 )
     y := 1
   else
   {
     MsgBox Error
     ExitApp
   }

   return, y
}

Code: Select all

f()
{
   if ( x = 0 )
   {
     y := 1
     return, y
   }

   MsgBox Error
   ExitApp
}
Rohwedder
Posts: 3642
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Questions about writing code

25 May 2020, 04:40

Hallo,
In my opinion, this would be more conducive to reading:

Code: Select all

f()
{
	if (x = 0)
		return, y := 1
	MsgBox Error
	ExitApp
}
Otherwise your third variation.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Haan, jongyun24, Recrix, takenbythedesert and 48 guests