diff --git a/README.md b/README.md index 1fd94d36f..df6398cad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Prelude -> Role models are important.
+> Role models are important.
> -- Officer Alex J. Murphy / RoboCop One thing has always bothered me as a Ruby developer - Python developers have a @@ -98,7 +98,7 @@ Translations of the guide are available in the following languages: > Nearly everybody is convinced that every style but their own is > ugly and unreadable. Leave out the "but their own" and they're -> probably right...
+> probably right...
> -- Jerry Coffin (on indentation) * @@ -268,15 +268,15 @@ Translations of the guide are available in the following languages: No space inside range literals. - ```Ruby - # bad - 1 .. 3 - 'a' ... 'z' + ```Ruby + # bad + 1 .. 3 + 'a' ... 'z' - # good - 1..3 - 'a'...'z' - ``` + # good + 1..3 + 'a'...'z' + ``` * Indent `when` as deep as `case`. I know that many would disagree @@ -613,27 +613,27 @@ Translations of the guide are available in the following languages: parentheses when the method doesn't accept any parameters. - ```Ruby - # bad - def some_method() - # body omitted - end + ```Ruby + # bad + def some_method() + # body omitted + end - # good - def some_method - # body omitted - end + # good + def some_method + # body omitted + end - # bad - def some_method_with_parameters param1, param2 - # body omitted - end + # bad + def some_method_with_parameters param1, param2 + # body omitted + end - # good - def some_method_with_parameters(param1, param2) - # body omitted - end - ``` + # good + def some_method_with_parameters(param1, param2) + # body omitted + end + ``` * Avoid the use of parallel assignment for defining variables. Parallel @@ -1027,21 +1027,21 @@ condition](#safe-assignment-in-condition). Use `Kernel#loop` instead of `while/until` when you need an infinite loop. - ```ruby - # bad - while true - do_something - end + ```ruby + # bad + while true + do_something + end - until false - do_something - end + until false + do_something + end - # good - loop do - do_something - end - ``` + # good + loop do + do_something + end + ``` * Use `Kernel#loop` with `break` rather than `begin/end/until` or @@ -1718,23 +1718,22 @@ no parameters. ``` * - Don't do explicit non-`nil` checks unless you're dealing with boolean - values. + Don't do explicit non-`nil` checks unless you're dealing with boolean values. - ```ruby - # bad - do_something if !something.nil? - do_something if something != nil + ```ruby + # bad + do_something if !something.nil? + do_something if something != nil - # good - do_something if something + # good + do_something if something - # good - dealing with a boolean - def value_set? - !@some_boolean.nil? - end - ``` + # good - dealing with a boolean + def value_set? + !@some_boolean.nil? + end + ``` * Avoid the use of `BEGIN` blocks. @@ -1861,7 +1860,7 @@ no parameters. ## Naming > The only real difficulties in programming are cache invalidation and -> naming things.
+> naming things.
> -- Phil Karlton * @@ -2050,7 +2049,7 @@ no parameters. > Good code is its own best documentation. As you're about to add a > comment, ask yourself, "How can I improve the code so that this > comment isn't needed?" Improve the code and then document it to make -> it even clearer.
+> it even clearer.
> -- Steve McConnell * @@ -2085,7 +2084,7 @@ no parameters. comment at all. -> Good code is like a good joke - it needs no explanation.
+> Good code is like a good joke - it needs no explanation.
> -- Russ Olsen * @@ -3284,18 +3283,18 @@ resource cleanup when possible. Don't use `String#gsub` in scenarios in which you can use a faster more specialized alternative. - ```Ruby - url = 'http://example.com' - str = 'lisp-case-rules' + ```Ruby + url = 'http://example.com' + str = 'lisp-case-rules' - # bad - url.gsub("http://", "https://") - str.gsub("-", "_") + # bad + url.gsub("http://", "https://") + str.gsub("-", "_") - # good - url.sub("http://", "https://") - str.tr("-", "_") - ``` + # good + url.sub("http://", "https://") + str.tr("-", "_") + ``` * When using heredocs for multi-line strings keep in mind the fact that they @@ -3316,7 +3315,7 @@ resource cleanup when possible. ## Regular Expressions > Some people, when confronted with a problem, think -> "I know, I'll use regular expressions." Now they have two problems.
+> "I know, I'll use regular expressions." Now they have two problems.
> -- Jamie Zawinski * @@ -3720,7 +3719,7 @@ your friends and colleagues. Every comment, suggestion or opinion we get makes the guide just a little bit better. And we want to have the best possible guide, don't we? -Cheers,
+Cheers,
[Bozhidar](https://twitter.com/bbatsov) [PEP-8]: http://www.python.org/dev/peps/pep-0008/