Created
March 8, 2012 10:44
-
-
Save ku1ik/2000357 to your computer and use it in GitHub Desktop.
Line breaking in Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example 1 | |
# Lets assume following line is longer than 80 cols and I want it to break it | |
Foobar.some_method.another_on(:with_some => :arg, :and_another => "one") | |
# Variant 1 | |
Foobar.some_method.another_on( | |
:with_some => :arg, :and_another => "one" | |
) | |
# Variant 2 | |
Foobar. | |
some_method. | |
another_on(:with_some => :arg, :and_another => "one") | |
# Variant 3 | |
Foobar.some_method.another_on(:with_some => :arg, | |
:and_another => "one") | |
# Variant 4 | |
Foobar.some_method.another_on(:with_some => :arg, | |
:and_another => "one") | |
# What would you do? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example 2 | |
# Lets assume following line is longer than 80 cols and I want it to break it | |
@asciicasts = Asciicast.order("created_at DESC").page(params[:page]).per(PER_PAGE) | |
# Variant 1 | |
@asciicasts = Asciicast. | |
order("created_at DESC"). | |
page(params[:page]). | |
per(PER_PAGE) | |
# Variant 2 | |
@asciicasts = Asciicast.order("created_at DESC").page(params[:page]). | |
per(PER_PAGE) | |
# Variant 3 | |
@asciicasts = | |
Asciicast.order("created_at DESC").page(params[:page]).per(PER_PAGE) | |
# Variant 4 | |
@asciicasts = Asciicast.order("created_at DESC").page(params[:page]) \ | |
.per(PER_PAGE) | |
# What would you do? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example 3 | |
# Lets assume following line is longer than 80 cols and I want it to break it | |
Foobar.some_method.another_on(positional_arg, :with_some => :arg, :and_another => "one", :foo => "barbazzz") | |
# Huh, now what? :P |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Agree on guys opinions above; one note from myself is I really hate breaking lines like in examples:
File 1: variant 3
File 2: variant 1 (what determines indentation here?), 2, 4
Nesting is two spaces per level. Period.