You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Positional arguments break when the last argument is a Hash:
# This does not work as expectedclassFooincludeGorillib::Modelfield:name,String,position: 0field:info,Hash,position: 1endf=Foo.new('joebob',{boring: true})f.name#=> "joebob"f.info#=> nil
This can be solved by either not having a Hash as the last positional argument, or by passing in the (apparently not optional) options hash whenever using the #new method with positional args. Neither is a great alternative:
# Never put Hashes last in positional argument listsclassFooincludeGorillib::Modelfield:name,String,position: 1field:info,Hash,position: 0# Reorganize the positions to avoid problemsendf=Foo.new({boring: true},'joebob')f.name#=> "joebob"f.info#=> {:boring=>true}# Or alternativelyclassFooincludeGorillib::Modelfield:name,String,position: 0field:info,Hash,position: 1endf=Foo.new('joebob',{boring: true},{})# Always remember this empty options hashf.name#=> "joebob"f.info#=> {:boring=>true}
Positional arguments break when the last argument is a Hash:
This can be solved by either not having a Hash as the last positional argument, or by passing in the (apparently not optional) options hash whenever using the
#new
method with positional args. Neither is a great alternative:The culprit is the
#extract_options!
method here.The text was updated successfully, but these errors were encountered: