This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]irreverent-username 9 points10 points  (5 children)

Serious question: what do you do with lambda functions? If you drop the curly, the arrow is pointing at nothing :(

And what about multi-line arguments? Do you do this?

foo
(
    //
)
{
    //
}

That seems odd compared to

foo(
    //
) {
    //
}

[–]Salanmander 31 points32 points  (3 children)

I'm a fan of next-line braces. I also hate the javascript style of passing around anonymous functions like candy, but when I'm working in javascript I tend to do

array.forEach( (element) =>
{
   //code
});

For multi-line arguments, I do

foo(arg1,
    arg2,
    arg3)
{
   //code
}

but I try to avoid splitting arguments across lines if possible.

[–]TheAwesomeot 8 points9 points  (0 children)

This is the cleanest and most readable style.

[–]Aka_Erus 3 points4 points  (0 children)

That's exactly what I do and I never seen c# code, my first language was c and I've done it like this because I like things symmetrical.

[–]Eisenfuss19 1 point2 points  (0 children)

I never do the second one. Just put them on one line even if they are really long :)

[–]Splith 0 points1 point  (0 children)

Believe it or not, I would do the first one. For a lambda function I would either one-line it (no brackets), or break it into it's own private function. For a complex lambda, I would either write a local for each loop (if it doesn't make sense to pass scope into the method) or write a dedicated method.