Closed
Description
I have a question about the multiline chaining example. You say:
When continuing a chained method invocation on another line keep the . on the second line.
# bad - need to consult first line to understand second line
one.two.three.
four
# good - it's immediately clear what's going on the second line
one.two.three
.four
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:
1.to_i
.to_s
syntax error, unexpected '.', expecting $end .to_s
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.
Metadata
Metadata
Assignees
Labels
No labels