Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guideline on symbol to_proc #183

Merged
merged 1 commit into from
Jun 23, 2014
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