10

μRant

Normal languages for longer ifs:

if ( (condition1)
|| (condition2)
|| (condition3))

Go:

if (condition1) ||
(condition2) ||
(condition3)

That OR at the *end* of line deeply disturbs me

Comments
  • 2
    if you put all these in the same line it makes more sense ocd-wise:)
  • 3
    @bad-frog not if condition is too long. Actually for brievety i suplemented from my case 'condition1' with something along of lines:

    (toAdd.String() == hardcodedNoGo && fromAdd.String() ==hardcodedNoGo)

    Lets just not get into details
  • 1
    @DubbaThony it was just to say: i know the pain, friend:)
  • 1
    I'm not sure if I'm getting this right.

    Is the OR / double pipe at the end a logical condition operator or a end of line seperator?

    End of line seperator would truly disturb me.
  • 3
    I also put the || at the end and always have - in C.
  • 1
    @ostream

    Well, not in golang, golang has some of weird syntax rules.

    If line looks like it might be like end of statement than its parsed as end of statement, so if you dont add OR before \n , "if condition" is valid statement.

    Edit:
    I find logical operators of bigger if significantly more readable on begining of a line, when they are aligned etc, but that may be personal thing
  • 0
    In python:

    any([condition 1, condition 2, condition 3, ... , condition n])
  • 2
    @bad-frog I was about to say this, I cant stand either of them OCD-wise 😅

    But real question though, Go doesn't allow OR operator at start?
  • 1
    @siddharth-neo

    No it does not allow it

    Go has weird rules with new lines.
  • 1
    @DubbaThony

    Wow! That's weird
Add Comment