What's a good way to find whether a hash is a subset of another hash (deep)?

Discussion in 'Ruby' started by dblock, Oct 7, 2011.

  1. dblock

    dblock Guest

    Anyone has a good way to implement is_subset_of for a hash? It needs
    to work for deep hashes obviously.

    I basically have json data returned in two formats: short and full. I
    want to make sure that the short format is an exact subset of the full
    format. When they aren't an exact subset I want the fields that exist
    in the first hash and don't exist in the second.

    Thanks,
    -dB.
    dblock, Oct 7, 2011
    #1
    1. Advertising

  2. Re: What's a good way to find whether a hash is a subset of anotherhash (deep)?

    On 10/07/2011 05:52 PM, dblock wrote:
    > Anyone has a good way to implement is_subset_of for a hash? It needs
    > to work for deep hashes obviously.


    Why is that obvious? At least for me it isn't.

    > I basically have json data returned in two formats: short and full. I
    > want to make sure that the short format is an exact subset of the full
    > format. When they aren't an exact subset I want the fields that exist
    > in the first hash and don't exist in the second.


    What does "short" and "full" exactly mean?

    Kind regards

    robert
    Robert Klemme, Oct 7, 2011
    #2
    1. Advertising

  3. * Robert Klemme <> (2011-10-08) schrieb:

    >On 10/07/2011 05:52 PM, dblock wrote:
    >> Anyone has a good way to implement is_subset_of for a hash? It needs
    >> to work for deep hashes obviously.

    >
    > Why is that obvious? At least for me it isn't.


    Maybe that will become clear, once we learn what a deep hash is. Is that
    one that Hashes as values? Or, beware, Hashes as keys? Or, something
    completely different?

    >> I basically have json data returned in two formats: short and full. I
    >> want to make sure that the short format is an exact subset of the full
    >> format. When they aren't an exact subset I want the fields that exist
    >> in the first hash and don't exist in the second.

    >
    >What does "short" and "full" exactly mean?


    It means that the short format is an exact subset of the full format.

    What is an exact subset? In what way in a Hash a set?

    mfg, simon .... l
    Simon Krahnke, Oct 9, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    17
    Views:
    824
    Hiran Chaudhuri
    Dec 6, 2005
  2. Thriving K.
    Replies:
    2
    Views:
    199
    Gennady Bystritsky
    Aug 4, 2009
  3. Siratinee Sukachai
    Replies:
    1
    Views:
    141
    7stud --
    Apr 22, 2011
  4. George Mpouras
    Replies:
    0
    Views:
    159
    George Mpouras
    Feb 17, 2013
  5. Ted Zlatanov
    Replies:
    0
    Views:
    144
    Ted Zlatanov
    Feb 21, 2013
Loading...

Share This Page