137
pertroo
7y

if (condition) {
//code
}

if you place your brackets like this, you're an awesome individual. Let's be friends

Comments
  • 34
    I like to do this:
    if(
    condition
    )
    {
    // TODO copy and paste from stackoverflow
    }

    :)
  • 4
    oh... :( all my whitespaces got removed
  • 2
    @juniordev o.O whhhhhhyyyyyyy??
  • 2
    @pertroo oh it's just a joke ;)
  • 1
    @juniordev i know haha
  • 5
    You. I like you.
  • 6
    Have to say I prefer the opening brace on a line of its own; helps me to see the block because I know the open brace is in the same column as the close.
  • 0
    @milkybarkid Its personal preference tho. Its just hard if someone else with other preferences starts working on it. But recently I needed to do this and i changed my preference for tabs. Needed to start using 1 space tabs instead of 4 and space after "if" which i didn't do normally
  • 6
    If (condition)
    {
    shit
    }
  • 2
    @Akio I find it's best to just conform to the project's coding style; makes it much more readable. For anything I'm writing from scratch, I have my own guidelines which I've in a document somewhere...
  • 0
    @Akio If you use VIM you can put a comment header in to define tabspacing, etc for that file, makes life so much easier:)
  • 0
    @milkybarkid Yes I agree with that but sometimes it may be hard to switch between the styles and you start using the wrong style in the wrong project... Like if you code in lang A for a long time, then start using lang B again and you write something that only works in lang A because you were not mentally there 100%
  • 0
    @milkybarkid I am one of those persons who doesn't know how 2 vim (should i learn it im fine with using nano) but you can do the same stuff in VSCode (which is what i use like 99% of the time right now) and that makes it handy so you can still just use tab.
  • 2
    Yay a friend *o*
  • 1
    @VonKavalier Yay! 😄😄
  • 0
    @milkybarkid I don't do it that way but it sounds useful
  • 1
    *high-fives*
  • 0
    Well, @pertroo you missed the indentation in the block. But it's ok! You're awesome too.
  • 1
    @joseglego, My bad @pertroo. devRant doesn't show the indentation in the web version. You're awesome :D
  • 1
    Just the way I do it too.
    Does this mean we can be friends?
  • 0
    I do that and when my teacher checks my code, she changed my brackets back... kms
  • 0
    public function doStuff()
    {
    if (condition) {
    //do stuff
    }
    }

    That's me :)
  • 1
    @cankarales Right here! :highfive !

    And all my coworkers give me shit for it when I slip up, too.

    You'd think there would be a whole set of tools dedicated to preformatting code when you load it, and converting it so it matches the style of the project it when you commit, but I've never seen anything like that actually in use.
  • 0
    @rantOverflow lmao your wife better not be on devRant 😂😂
  • 0
    And if you do this:

    if (condition) statement;

    …you can get out.
  • 0
    @rantOverflow Get out.

    😉
  • 0
    I kinda like the verbose Elixir style

    if(🍦, [{:do, :smile}, {:else, :cry}])
  • 0
    If you use whatever then Beautify on save, we are friends
  • 0
    We can be friends now
Add Comment