Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8358809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:55:24+00:00 2026-06-09T10:55:24+00:00

Possible Duplicate: Is there any difference between the :key => “value” and key: “value”

  • 0

Possible Duplicate:
Is there any difference between the :key => “value” and key: “value” hash notations?

What’s the difference between this:

method: :delete

and this?

:method => :delete

I’m guessing it has to do with different versions of Rails but not sure. I have only worked in Rails 3.x.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T10:55:26+00:00Added an answer on June 9, 2026 at 10:55 am

    They are completely equivalent, except the first can only be used since ruby 1.9 (and higher, of course).

    In ruby 1.8 the hash syntax used the =>, also known as the hash rocket. You could put anything in front, and anything behind, but the thing in front is your key, behind the value. If you have a symbol as key, and a symbol as value, you would write:

    :method => :delete
    

    But you could also write

    { 1 => 'one', :2 => 'two', 'THREE' => 3 }
    

    Now, for ruby 1.9.x, a new shorter syntax was introduced. Since most people use symbols as keys, you can now write:

    method: :delete
    

    Which is just a shorter/cleaner version. Also note that it is possible to mix both styles, which in some cases is needed.

    E.g. in ruby 1.8 you would write:

    { :class => 'smthg', :'data-type' => 'a type' }
    

    This would translate to the following in ruby 1.9

    { class: 'smthg', :'data-type' => 'a type' }
    

    Note that you can still keep using the “old” hash syntax as well. It is a matter of preference. Personally for hashes with only symbols as keys, I use the clean/short version. I generally try not to mix hash-style in a single hash 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: what is “=null” and “ IS NULL” Is there any difference between
Possible Duplicate: Is there any difference between :key => value and key: value assignments?
Possible Duplicate: Is there any difference between “foo is None” and “foo == None”?
Possible Duplicate: C++: “std::endl” vs “n” I'm wondering if there is any significant difference
Possible Duplicate: Any way to “reboot” the JVM? Is there any option to restart
Possible Duplicate: jQuery single selector vs .find() Is there any difference between $(Parent Child)
Possible Duplicate: Differences in string compare methods in C# Is there any difference between
Possible Duplicate: In Python, what is the difference between “.append()” and “+= []”? In
Possible Duplicate: Is there any difference between Group By and Distinct What's the difference
Possible Duplicate: c difference between malloc and calloc Is there any situation where you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.