Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #7386
| Newsgroups | comp.lang.ruby |
|---|---|
| Date | 2018-04-09 08:01 -0700 |
| Message-ID | <61b0c250-c95a-4614-9cba-95b804aec2a7@googlegroups.com> (permalink) |
| Subject | Compare hashes and report where the change was |
| From | Abdel Latif <mlotfi2005@gmail.com> |
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'
Thanks
Back to comp.lang.ruby | Previous | Next — Next in thread | Find similar
Compare hashes and report where the change was Abdel Latif <mlotfi2005@gmail.com> - 2018-04-09 08:01 -0700 Re: Compare hashes and report where the change was Robert Klemme <shortcutter@googlemail.com> - 2018-04-09 18:15 +0200
csiph-web