Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

    if( ! fits)
Why this (constently) terrible formatting though? Never seen anyone using this style.


sort by: page size:

So you don't somehow end up with mismatched curly braces?

I might paste something, but mess up and forget to select one of the curly braces or select too many. I am seriously considering closing all of them on the same line in this style

    if blah {
        thing; }

    // If statements require brace brackets, and do not require parens.
Even if it is single line?

Tip: make sure you hit space two times before writing your code so it renders correctly:

var not_formatted;

  var formatted;

> Set IFS to just newline and tab, if you can, to reduce the risk of mishandling filenames with spaces.

should be: reduce the risk when mishandling filenames.

If your handling of filenames depends on IFS, you are already in big trouble!


I see something different in there.

F(condition1,

Condition2)

Is worse than

F(

  Condition1,

  Condition2
)

The problem isn't tabs or spaces, it's trying to align to the length of the function name instead of adding a new line


  [ "Why not just use"
  , "this indentation style"
  , "to avoid the problem"
  , "in the first place?"
  ]

Because it's Java.

Also, significant whitespace is a pain in the ass.


I agree, there are like 7 lines that bunch together logic using commas.

This one has three operations in one line:

  newEl.className = newEl.className.replace(' f', ''), length++, hasFood = false;

> how does one format code in HN?

Two space indent.


Code formatting is just blockquotes.

  So one empty space followed by indented text (2 or more spaces)

The formatting will not be pretty.

Source: I tried this.


  i should probs be working Lmfao          
you can cheat by adding trailing spaces

oops,

  ^(?!.*(.)(.)\2\1).*$
With proper formatting hopefully.

    - Four spaces at the start of a line makes 'preformat',
      useful for code or lists. 
      - You'll want to manually wrap long lines, though.

>has somewhat odd syntax

says the programmer using significant whitespace

runs for cover


I was wondering the same thing too. And even if you wanted to keep this odd behaviour, it could be better written as

  /^[izehsglbo][izehsgl]o?$/

Actually it's only 2 spaces.

  Like this.
    Not this.

If they're surrounded by spaces it goes ok...

    x ** y

It spaces them evenly if you have multiple subsequent lines of them. Readable enough:

    var (
        i, j        int
        foobarStuff string
        bebop       bool
    )
What's not readable?
next

Legal | privacy