Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions style/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ Ruby
* Prefer double quotes for strings.
* Prefer `&&` and `||` over `and` and `or`.
* Prefer `!` over `not`.
* Prefer `&:method_name` to `{ |item| item.method_name }` for simple method
calls.
* Use `_` for unused block parameters.
* Use `%{}` for single-line strings needing interpolation and double-quotes.
* Use `{...}` for single-line blocks. Use `do..end` for multi-line blocks.
Expand Down
8 changes: 6 additions & 2 deletions style/samples/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ def method_with_multiline_block
some_method_after_block(should_follow_after_newline)
end

def method_with_single_line_block
items.map { |item| item.some_attribute }
def method_with_single_method_block
items.map(&:some_attribute)
end

def method_with_oneline_combined_methods_block
items.map { |item| "#{item.one} #{item.two}" }
end

def method_that_returns_an_array
Expand Down