small medium large xlarge

Back to: All Forums  Swift Style
Generic-user-small
15 Dec 2016, 17:59
Erica Sadun (5 posts)

Two? Three? Four? Tabs? I’m a 4-denter myself.

Generic-user-small
15 Dec 2016, 23:35
Shoaib Hannani (1 post)

4 spaces has been the norm for quite some time. Been doing so for the past 22 years.

Generic-user-small
15 Dec 2016, 23:43
Erica Sadun (5 posts)

I was surprised by the 3-denter support on Twitter, for example here and here

Profile_square_1000_pragsmall
22 Dec 2016, 20:49
Benjamin Snider (1 post)

Fibonacci denting?

class Foo {
 func bar() {
   if a > b {
     // at 5
     if c > d {
        // at 8
        if e > f {
             // at 13, etc.
        }
     }
   }
 }
}

In all seriousness, I see most Apple platform code as being 4-dented (because objc), whereas a lot of multi-platform Swift is 2-dented.

Generic-user-small
22 Dec 2016, 22:37
Erica Sadun (5 posts)

How about some pow2-dentage then?

class Foo {
  func bar() { // 2
    if a > b { // 4
          if c > d { // 8
                      if e > f { // 16
                      }
          }
    }
  }
}
Generic-user-small
27 Apr 2017, 06:12
Vince O'Sullivan (1 post)

Obviously, indenting should be done with tabs. Everything else is evil.

mmm. The Power Of Two looks interesting… How about The Power Of Two Tabs? I think we’re on to something.

You must be logged in to comment