Last active
          October 4, 2017 16:18 
        
      - 
      
 - 
        
Save moklett/a123b1b8853d01aa1c01411a465a7b30 to your computer and use it in GitHub Desktop.  
    Ruby Double Splat is a bit like Javascript Spread
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | a = { a: "a" } | |
| b = { b: "b" } | |
| { **a, **b } | |
| #=> {:a=>"a", :b=>"b"} | |
| { z: "z", **a, **b } | |
| #=> {:z=>"z", :a=>"a", :b=>"b"} | |
| { a: "AAA", **a, **b } | |
| #=> {:a=>"a", :b=>"b"} | |
| { **a, **b, a: "AAA" } | |
| #=> {:a=>"AAA", :b=>"b"} | |
| # Compare to how I may have done merges before... | |
| merged1 = a.merge(b) | |
| merged2 = { **a, **b } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment