# Indentation in stdlib

**URL:** <https://www.ruby-forum.com/t/indentation-in-stdlib/193388>\
**Category:** Ruby\
**Created:** [August 16, 2010, 10:09pm UTC](https://www.ruby-forum.com/t/indentation-in-stdlib/193388 "2010-08-16T22:09:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philipp\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@Philipp\_K](https://www.ruby-forum.com/u/Philipp_K)\
**Post date:** [August 16, 2010, 10:09pm UTC](https://www.ruby-forum.com/t/indentation-in-stdlib/193388/1 "2010-08-16T22:09:08Z")

</div>

Annoyed about inconsistent indentation in some files in the stdlib  
(e.g. ipaddr.rb) …

Sometimes 4 indentations are written as 8 spaces and sometimes (in the  
same file) as 1 tab.

Example:

def initialize(addr = ‘::’, family = Socket::AF\_UNSPEC)  
if !addr.kind\_of?(String)  
case family  
when Socket::AF\_INET, Socket::AF\_INET6  
set(addr.to\_i, family)  
@mask\_addr = (family == Socket::AF\_INET) ? IN4MASK : IN6MASK  
return  
^spaces  
when Socket::AF\_UNSPEC  
^spaces  
raise ArgumentError, “address family must be specified”  
^tab  
else  
^spaces  
raise ArgumentError, “unsupported address family: #{family}”  
^tab  
end  
end

It happens to look OK if and only if your tab-width is set to 8.  
Otherwise a mix of spaces and tabs looks totally unreadable.

I have a preference for 1 tab (without expansion) per indentation  
(so everybody can set the tab-width according to their personal  
liking) but I’m fine with a fixed number of spaces per indentation.

However a mix of spaces and tabs is the worst of both ways.  
Just saying … No offense.

Philipp

---

<div class="post-metadata">

**Author:** ![Philipp\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@Philipp\_K](https://www.ruby-forum.com/u/Philipp_K)\
**Post date:** [August 17, 2010, 3:18am UTC](https://www.ruby-forum.com/t/indentation-in-stdlib/193388/2 "2010-08-17T03:18:16Z")

</div>

On Tue, Aug 17, 2010 at 05:08:31AM +0900, Philipp K. wrote:

> ```
> case family
> 
> ```
> 
> ^spaces  
> liking) but I’m fine with a fixed number of spaces per indentation.
> 
> However a mix of spaces and tabs is the worst of both ways.  
> Just saying … No offense.

Probably this is by accident. If you check the code style in the wiki,  
it says Ruby stdlib should be 2 space indent:

[http://redmine.ruby-lang.org/wiki/ruby/DeveloperHowTo](http://redmine.ruby-lang.org/wiki/ruby/DeveloperHowTo)
