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. Advertisements

  2. Why is that obvious? At least for me it isn't.
    What does "short" and "full" exactly mean?

    Kind regards

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

  3. 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?
    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. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.