On Fri, May 22, 2009 at 1:10 PM, Balint Erdi <balint.erdi / gmail.com> wrote: > Hi, > > Deleting (vs. just fetching) the hash key from an options hash that > was passed in as an argument to the method seems prevalent. I saw it > in several high-quality OS projects (e.g DataMapper, Rails) > > For example: > > unless options.delete(:only_path) > ¨Âòì ¼¼ ¨ïðôéïîó®äåìåô娺ðòïôïãïì© üü §èôôð§> ¨Âòì ¼¼ §º¯¯õîìåóó õòì®íáôã訢º¯¯¢© > .. > end > > I wonder what advantage the above snippet has instead of writing: > > unless options[:only_path] > ¨Âòì ¼¼ ¨ïðôéïîóÛºðòïôïãïìüü §èôôð§> ¨Âòì ¼¼ §º¯¯õîìåóó õòì®íáôã訢º¯¯¢© > .. > end > > Thank you, > Balint > > It's usually a good idea to consume the option if you are receiving options that any methods you will subsequently call, won't need (or may break when receiving) them. i.e. options specific for the particular method. If you are not going to pass the options onto other methods, then there is nothing wrong with just referencing them. Andrew Timberlake http://ramblingsonrails.com http://MyMvelope.com - The SIMPLE way to manage your savings