-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
multiline chaining #169
Comments
Also, putting 1.to_i
# failure
.to_s 1.to_i.
# success
to_s |
2013年5月16日木曜日 Chris Bandy [email protected]:
|
Without the period on the end it looks like a complete statement. This would cause me to stop reading for anything new. Since the second has issues and is only valid in 1.9 why don't we stick with the period at the end. Should there also be a note that long chains like this should be avoided. |
This changes where the '.' lives from the second line to the first line in the expression. Having no '.' at the end of the first line makes that line appear to be complete, but you must read ahead to the next line in order to see that the expression continues. This closes issue rubocop#169
it appears to me that making dot on second line is completely inconsistent with multiple line
|
@equivalent Unfortunately this is true. But then again - Ruby is full of inconsistencies :-) Hopefully some day this will be fixed. |
:) ... I like many of your points on syntax and it make sense that developer want to know what is happening on second line when he does multiple line chaining (specially in function returning value), however I find it completely inelegant to do stuff one way when chaining and another way when working with comparison operators obviously I can do
but that is crushing my soul one final argument for my theory: I see your point that developer is lost when chaining on multiple lines without indentation and may assume that block below is just returning three
... but when developer use extra indentation, he automatically knows that something else happened above
|
Btw, shouldn't the second line be indented as much as the last call on the first line?
This is the indentation proposed for multi line method calls
|
Oh, this has already been proposed by @jdalbert on #176. |
fuadsaud, this is the best style |
i concur with the argument against. |
I decided to resolve this in a diplomatic manner, given the lack of consensus. See related commit. |
I have a question about the multiline chaining example. You say:
However, the example labelled good does not work for me (using 1.9), while the example labelled bad does. I thought the dot at the end of the line was necessary in order to tell the ruby interpreter that the expression continued.
Here's an example:
Update:
OK, I've just figured out the issue is a 1.9 vs. 2.0 difference in syntax. The good example is only valid ruby in 2.0. I think there should be a note added to avoid confusion for people using 1.9. What is the recommended syntax for 1.9 ?
Thanks guys.
The text was updated successfully, but these errors were encountered: