Comments (7)
Just because I'm new to the ruby community, why is this not something people do:
Mailer.deliver(
to: "[email protected]",
from: "[email protected]",
subject: "Important message",
body: source.text
)
Scatches the alignment itch without looking too adhoc with the bracket placement. Yeah, it's 2 extra lines, but that separation is at a visually useful place. And vertical space is in abundance, while horizontal space is a commodity. Adding 8+x extra spaces per line (where x can approach infinity) seems like funny use of space when 2 would do :)
But hey, guessing it's just how it is, hey
from ruby-style-guide.
Just to throw in my two cents:
Mailer.deliver(
to: "[email protected]",
from: "[email protected]",
subject: "Important message",
body: source.text
)
It preserves alignment of keys and values, maintains the symmetry of indentation for lines containing opening parens and closing parens (e.g., flush with the current indentation), and preserves a constant two-space indentation for all circumstances (I can't seem to stand indentation of anything other than exactly two spaces at a time).
from ruby-style-guide.
Definitely. My experience shows that the aligned style is the most popular style (and it's also my preferred style). Note that in that your example there is only one method param.
from ruby-style-guide.
Oh yes, oops, I'm so used to supplying hashes to methods! Although a hash is probably most common when a method needs a lot of config passed.
from ruby-style-guide.
#I quite like these kind of things, but they're both very adhoc
Mailer.deliver(to: "[email protected]",
from: "[email protected]",
subject: "Important message",
body: source.text)
#or inspired by rubinius stack traces:
Mailer.deliver(to: "[email protected]",
from: "[email protected]",
subject: "Important message",
body: source.text)
from ruby-style-guide.
Ah, yep. That's exactly what @patcon suggested.
from ruby-style-guide.
👍 to the suggestion by @patcon and @stouset, the extra horizontal space is invaluable, especially if dealing with an 80-character line limit.
from ruby-style-guide.
Related Issues (20)
- Typo in loop with break? HOT 1
- New exception classes HOT 1
- File naming with acronyms HOT 3
- `extend`ing objects at runtime HOT 2
- Usage of do...end block syntax in conditionals HOT 1
- Compact case statements: is there a way to enforce single-line when? HOT 4
- Add a rule for method calls in multiline blocks HOT 3
- Good practice - Heredocs in hash HOT 2
- Whitespace around certain operators HOT 6
- Prefer `grep` and `grep_v` to `select`/`reject` that does a regexp match (Ruby 3+)
- Numbered parameters HOT 2
- Is there a typo in the Suppressing Exceptions section? HOT 2
- Add guidance for safe navigation operator (`&.`) HOT 3
- Why not allowing multi-line ternary operator? HOT 2
- `using` in "Consistent Classes" HOT 6
- The '%w' and '%i' syntax for arrays is just a bad idea HOT 10
- Consider definining `#nil?` method a bad practice HOT 4
- Enforce no parentheses for `include`, `extend`, etc?
- [Idea] Write "good" before "bad" examples HOT 2
- /.,m/.,m/.,m/.,m./,m.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-style-guide.