Code Monkey home page Code Monkey logo

Comments (7)

patcon avatar patcon commented on May 12, 2024 42

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.

stouset avatar stouset commented on May 12, 2024 11

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.

bbatsov avatar bbatsov commented on May 12, 2024

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.

Odaeus avatar Odaeus commented on May 12, 2024

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.

markburns avatar markburns commented on May 12, 2024
#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.

stouset avatar stouset commented on May 12, 2024

Ah, yep. That's exactly what @patcon suggested.

from ruby-style-guide.

as016194 avatar as016194 commented on May 12, 2024

👍 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.