Official Everybody Edits Forums

Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?

You are not logged in.

#1 2017-08-22 03:26:57

italkalotfromee
Member
Joined: 2015-05-08
Posts: 117

Does it matter which way? Is there a better way?

         
/* Edit type 1 */          
if (msg[0] == "edit") /* Checks if msg = edit */
        if (admin.Contains(m.GetString(1))) /* checks to see if added to admins 
               con.Send("say", "/giveedit " + msg[1]); /* gives edit to the called player */

/* Edit type 2 */
if (msg[0] == "edit") /* Checks if msg = edit */
{
       if (admin.Contains(m.GetString(1))) /* checks to see if added to admins list */
         {
                con.Send("say", "/giveedit " + msg[1]); /* gives edit to the called player */
         }
}

What's the difference between these if any and why do some people put brackets and some don't? Can it bother future code? Is there really any specifc way to do it? Does one look better or something? I really never understood the fact why some people code like example: "Edit type 1" then they do in: "Edit type 2"

Not only that but it bothers some people when they don't read code the same way they code it.. [hope that made sense. //forums.everybodyedits.com/img/smilies/neutral ]


FluxBB bbcode test

Offline

#2 2017-08-22 04:48:38

Vinyl Melody
Formerly BananaMilkShake
Joined: 2016-06-19
Posts: 616

Re: Does it matter which way? Is there a better way?

Both are fine. It's up to the user.

I don't use brackets unless I need to use multiple lines.


cb0de83627.png
Thanks to: Ernesdo (Current Avatar), Zoey2070 (Signature)

Very inactive, maybe in the future, idk.

Offline

#3 2017-08-22 06:00:15

Zumza
Member
From: root
Joined: 2015-02-17
Posts: 4,645

Re: Does it matter which way? Is there a better way?

You always have to use brackets when you're isolating multiple instructions. It's called a block of code.
On the other hand if you have a single instruction you often don't need to write brackets.
Some code-styling guides recommend not to put brackets if there's only one instruction, other specify to always do.
It's just a matter of esthetics.


Everybody edits, but some edit more than others

Offline

#4 2017-08-22 14:02:52

Tomahawk
Forum Mod
From: UK
Joined: 2015-02-18
Posts: 2,830

Re: Does it matter which way? Is there a better way?

if (msg[0] == "edit" && admin.Contains(m.GetString(1))) con.Send("say", "/giveedit " + msg[1]);

Yea boi.

I never use 1. Reminds me too much of languages that use tabbing instead of braces, and I hate em.


One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.

Offline

Wooted by:
Tomahawk1503406972674324

Board footer

Powered by FluxBB

[ Started around 1713508836.7919 - Generated in 0.042 seconds, 10 queries executed - Memory usage: 1.41 MiB (Peak: 1.53 MiB) ]