3-22 Ruby 编码规则(个人整理)
编码规则
https://github.com/thoughtbot/guides/tree/master/style/ruby
*Use a trailing comma after each item in a multi-line list, including the last item.
a = [
:one,
:two,
:three,
]
- Prefer
detect
overfind
. 0d819844 - Prefer
select
overfind_all
. 0d819844 - Prefer
map
overcollect
. 0d819844 - Prefer
reduce
overinject
. #237 - Prefer double quotes for strings. #174
- Prefer
&&
and||
overand
andor
. #153 - Prefer
!
overnot
. #195 - Prefer
&:method_name
to{ |item| item.method_name }
for simple method calls. #183 - Prefer
if
overunless
. #254
- Use
def self.method
, notdef Class.method
orclass << self
. - Order class methods above instance methods.