Skip to content

Commit

Permalink
spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
elbrujohalcon committed Sep 5, 2014
1 parent 7ad5d1f commit 87e158d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,15 @@ Table of Contents:
##### Spaces over tabs
> Spaces over tabs, 2 space indentation.
*Examples*: [spaces.erl](src/spaces.erl)
*Examples*: [indent.erl](src/indent.erl)

*Reasoning*: This is *not* intended to allow deep nesting levels in the code. 2 spaces are enough if the code is clean enough, and the code looks more concise, allowing more characters in the same line.

***
##### Use your spacebar
> Surround operators and commas with spaces.
```erlang
% bad
my_function(My,Space,Bar)->[is,not,working].

% good
my_function(Hey, Now, It) -> ["works" ++ "again" | [hooray]]].
```
*Examples*: [spaces.erl](src/spaces.erl)

*Reasoning*: Again, easier to find / read / etc.

Expand Down
31 changes: 5 additions & 26 deletions src/spaces.erl
Original file line number Diff line number Diff line change
@@ -1,30 +1,9 @@
-module(spaces).

-export ([bad/0, better/0, good/0]).
-export([bad/3, good/3]).

%% @doc inconsistent
bad() ->
try
ThisBlock = is:indented(with, two, spaces),
that:is_good(ThisBlock)
catch
_:_ ->
{this, block, is, indented},
[with, four, spaces]
end.
% @doc no spaces
bad(_My,_Space,_Bar)->[is,'not',working].

%% @doc consistent, but with 4 spaces
better() ->
receive
{this, block} -> is:indented(with, four, spaces);
_That -> is:not_good()
after 100 ->
but:at_least(it, is, consistent)
end.

%% @doc good
good() ->
case indentation:block() of
{2, spaces} -> me:gusta();
{_, _} -> not_sure:if_gusta()
end.
% @doc spaces!!
good(_Hey, _Now, _It) -> ["works " ++ "again, " | [hooray]].

0 comments on commit 87e158d

Please sign in to comment.