Which is better
#1

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");
Reply
#2

Better is first
Reply
#3

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

Clearer and neater
and easier to handle it
Reply
#5

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
Reply
#6

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?
Reply
#7

Best:

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


Forum Jump:


Users browsing this thread: 1 Guest(s)