Look at the discussion on this thread . I am not able to follow how having a block to a fetch is a better solution.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
In the first patch on Rails ticket #4558:
This line executes the basename and capitalize functions and then passes the result into
Hash#fetchregardless of if a value for :alt already exists in the options hash.In the updated patch:
The same basename/capitalize code is only executed when
Hash#fetchneeds the default value (i.e. when the :alt key does not exist in the options hash). This means the (possibly expensive) calculation of the default value can be skipped if it’s not needed.See the documentation on
Hash#fetchfor more details.