-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Style/HashSyntax to support hash rockets when pointing to symbols #1437
Comments
The cop is already supporting this style ( |
I mean a different situation, to make it more clear: # bad
{key: :value}
{:key => 'valeu'}
{:key => 1}
# good
{:key => :value}
{key: 'value'}
{key: 1} |
OK, now I get what you mean. Guess we can add another enforced style for this. |
👍 |
Excuse me for stupid question @brodock, but can you please briefly describe benefits of hash rocket usage when it points to symbols? |
@maksar: no hidden secret or ancient optimization, it's just a f... lot more readable when using good code highlight (github doesn't help much demonstrating it). get this example: { attribute: true, size: 50, height: 60, type: :something, points: 333, title: 'Some phrase goes here', subtitle: "now with #{interpolated} string"}
{ attribute: true, size: 50, height: 60, :type => :something, points: 333, title: 'Some phrase goes here', subtitle: "now with #{interpolated} string"} find the value of ":type" key. another one: { from_a: :to_b, from_c: :to_d, from_d: :to_c }
{ :from_a => :to_b, :from_c => :to_d, :from_d => :to_c } which one you think it's more clear? |
@brodock Agree with you on clarity point. However, line length counts too.
in my code, which solves both 'where the value of given key' and 'why lines are so long' problems. Thanks for you explanation, though. In short cases hash rockets do indeed look nicer, besides, can't still be avoided with string keys... |
I have an idea on how to implement this feature and have started on some code for it. I will try to put together a pull request soon. |
While this is not covered by the ruby style guide yet, I've seen benefits of using hash rocket instead of 1.9 when pointing to symbols:
As I beleive this may not be consensus, I suggest to make it specific configurable:
This may be related to #519.
The text was updated successfully, but these errors were encountered: