jeudi 12 août 2021

Value in a Hash is in another Hash Ruby

I have two hashes, one have all values, the second one have specific values that are also included in the first one. I want to create a third one that have all values of the first one but excluding the values of the second one.

Example

Hash one function:

def get_states
      States.new(
          name: :All,
          dimensions: all_states)
 end

def isolated_states
      get_states.dimensions.select {|d| d.isolate_code?}
    end

Then here I want to do something like

states: get_states.select{|d| d.include(isolates_states)}

FinalStage.new(name: state_name, states: get_states)

Aucun commentaire:

Enregistrer un commentaire