• Compare hashes and report where the change was

    From Abdel Latif@21:1/5 to All on Mon Apr 9 08:01:58 2018
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Robert Klemme@21:1/5 to Abdel Latif on Mon Apr 9 18:15:51 2018
    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/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)