Search
 
SCRIPT & CODE EXAMPLE
 

RUBY

ruby deep merge

h1 = { a: true, b: { c: [1, 2, 3] } }
h2 = { a: false, b: { x: [3, 4, 5] } }

h1.deep_merge(h2) # => { a: false, b: { c: [1, 2, 3], x: [3, 4, 5] } }

h1 = { a: 100, b: 200, c: { c1: 100 } }
h2 = { b: 250, c: { c1: 200 } }

h1.deep_merge(h2) { |key, this_val, other_val| this_val + other_val }
# => { a: 100, b: 450, c: { c1: 300 } }
Comment

PREVIOUS NEXT
Code Example
Ruby :: rails change date format 
Ruby :: rails strftime 
Ruby :: how to format date and time in rails 
Ruby :: table name from rails console 
Ruby :: rails form fields 
Ruby :: ruby raise argumenterror 
Ruby :: rails add reference 
Ruby :: ruby if 
Ruby :: concatenate arrays in ruby 
Ruby :: sort array of hashes ruby 
Ruby :: ruby remove last element of string 
Ruby :: rails catch mail error 
Ruby :: random datetime ruby 
Ruby :: rails image tag data attribute 
Ruby :: how to find even number in an array ruby 
Ruby :: how to reset migrations rails 
Ruby :: ruby hello world 
Ruby :: ruby includethis or that 
Ruby :: rbenv not changing version 
Ruby :: ruby and or 
Ruby :: rails form validation custom message 
Ruby :: rails many to many relationship same model 
Ruby :: SoC partial class 
Ruby :: ruby 3 one line method 
Ruby :: ruby ** 
Ruby :: Or even multiple scope parameters. For example, making sure that a teacher can only be on the schedule once per semester for a particular class. 
Ruby :: OTP SMS Mobile Verification in Ruby 
Ruby :: class ruby 
R :: random integer in r 
R :: defulat function values R 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =