SA-MP Forums Archive
Which is better - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Which is better (/showthread.php?tid=542240)



Which is better - Raefal - 18.10.2014

Which is better ?
Код:
	new a=3, b=3;
	if(a == 5)
	{
	    print("A = 5");
	}
	else if(b == 3)
	{
        print("B = 3 Elseif");
	}
	else
	{
	    print(" Penasaran ");
	}
Or

Код:
	new a=3, b=3;
	if(a == 5)
		return print("A = 5");
		
	if(b == 3)
		return print("B = 3);

	print("Else");



Re: Which is better - osman2571 - 18.10.2014

Better is first


Re: Which is better - Raefal - 18.10.2014

Can u give me reason, why the first is better?


Re: Which is better - osman2571 - 18.10.2014

Clearer and neater
and easier to handle it


Re: Which is better - cessil - 18.10.2014

I can't find pawn coding conventions, but it's a C-like language so you could take a look at http://users.ece.cmu.edu/~eno/coding...rd.html#ifthen
although conventions might vary depending on which site you visit

there are several for as3, this one is my favourite because it made the most sense and looked the most human readable and I used it for pawn too
http://wiki.opensemanticframework.or...ding_Standards


Re: Which is better - austin070 - 18.10.2014

It really depends on your style. I prefer to use else-if statements because they're failsafe; in the case that I do need to have them in else-if form, they already are.

@cessil is this what you were looking for?


Re: Which is better - Lawbringer - 18.10.2014

Best:

Код:
new a=3, b=3;
if(a == 5) print("A = 3");
else if(b == 3) print("B = 3 Elseif");
else print(" Penasaran ");