Ruby on Rails
Monday, March 24, 2014
Visually I find the hash rocket style really unnerving.. I don't know why! Just like the "<<" which is supposed to be more efficient than "+". Just pains me to see them but I'm trying to adhere to best practices too.
On Friday, March 21, 2014 11:51:14 AM UTC+8, tamouse wrote:
-- On Friday, March 21, 2014 11:51:14 AM UTC+8, tamouse wrote:
On Thu, Mar 20, 2014 at 7:45 PM, Vladimir Rybas <vladim...@gmail.com> wrote:
> In the [Github Ruby Styleguide][1] there's a note about Hashes:
>
> `Use hashrocket syntax for Hash literals instead of the JSON style
> introduced in 1.9.`
>
> I guess the reason is that if you use hashrocket syntax, you can use
> any type as a hash key, while with colon the keys are `Symbol` only.
> So, you'll (pretty much) always have two styles in your app.
>
> Strict styleguides are important. What if we all start to do crazy
> things like `@VARIABLE` or `CamelCaseConstant = [1, 2, 3]`? (and I've
> seen such cases, unfortunately).
>
> But in this particular case with hashes, I personally use mixed style.
> So, colon for simple key-value hashes, where value is not a `Symbol`
> itself. And hashrocket for mixed DSL hashes with "complex" values.
>
> [1]: https://github.com/styleguide/ruby
I have been generally following the GH style guide, but not the
hashrocket thing, unless a client mandates it. One thing to note:
Github itself as a huge codebase, the main site still runs Rails 2.x,
and it makes sense when you have a long term code base, to keep a
consistent style across it. I'm not so sure that one needs to be so
slavish to that though if you aren't writing code for GH.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b148933a-a10e-4da6-b57a-c98adba67ede%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment