Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.ruby Subject: Re: Compare hashes and report where the change was Date: Mon, 9 Apr 2018 18:15:51 +0200 Lines: 26 Message-ID: References: <61b0c250-c95a-4614-9cba-95b804aec2a7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net wImhtQPP55/zlFwon3CTXwnpRnpsx+hikdTKVuIdg3tzJMmoc= Cancel-Lock: sha1:TdEE9y2BTwHirUwfgjM5276lTtY= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 In-Reply-To: <61b0c250-c95a-4614-9cba-95b804aec2a7@googlegroups.com> Content-Language: de-DE Xref: csiph.com comp.lang.ruby:7387 On 09.04.2018 17:01, Abdel Latif wrote: > I would like to compare two hashes, for example: > > array1 = [{'id' => 124, 'name' => 'Kamal', 'job' => 'manager'}, > {'id' => 314, 'name' => 'John', 'job' => 'developer'}] > array2 = [{'id' => 124, 'name' => 'Kamal', 'job' => 'managerZ'}, > {'id' => 314, 'name' => 'JohnDD', 'job' => 'developer'}] > > The id is not always "id", it could be UserID or EmployeeID or else, need to create a : > > def compare_rows(array1,array2,id) > > I want to report: > > row with id equal 124, job changed from 'manager' to 'managerZ' > row with id equal 314, name changed from 'John' to 'JohnDD' What was your question again? Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/