Project

General

Profile

Bug #16371

Updated by sawa (Tsuyoshi Sawada) over 4 years ago

Here is an issue with a weird wierd behavior of a ruby double splat operator:  

 ``` 
 a = {a: 'a'} 
 b = {'b' => 'b'} 

 {x: 'x', **a} 
 #=> {:x=>"x", :a=>"a"} 

 {x: 'x', **b} 
 #=> TypeError (hash key "b" is not a Symbol) 
 ``` 

 When But when I do that implicitly, implicitly it works: 

 
 ``` 
 {x: 'x', **{'b' => 'b'}}  
 #=> {:x=>"x", "b"=>"b"} 
 ``` 

 At In the same time: 

  
 ``` 
 {**{'b' => 'b'}} 
 # TypeError (hash key "b" is not a Symbol) 
 ``` 

 From my point of view, it definitely works inconsistently. inconsistently 

 Could you help with this that example or give an advice? (maybe ( maybe I used it incorrectly?) incorrectly use it? )

Back