Can someone help me with this:
ruby 2.7.3p183
Here is the situation, this method:
def send_request(url, payload = {}, internal_proxy: true)
...
and this call
send_request('random_address', { foo: :bar })
Returns me:
Traceback (most recent call last):
5: from C:/Ruby27-x64/bin/irb.cmd:31:in `<main>'
4: from C:/Ruby27-x64/bin/irb.cmd:31:in `load'
3: from C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
2: from (irb):4
1: from (irb):1:in `send_request'
ArgumentError (unknown keyword: :foo)
I understand that it is trying to match the optional parameters, but why? shoudn't 'payload' variable receive the parameter?, I tried to search for an explanation, but I can't seem to find any
I used to use internal_proxy variable just like payload;
def send_request(url, payload = {}, internal_proxy = true)
but rubocop warns me;
Use keyword arguments when defining method with boolean argument.
(convention:Style/OptionalBooleanParameter)
Does hash on the first not optional parameter always count as the keyword argument? If so, how can I get the expected behaviour I mentioned above? (unless is a bad practice for some reason)
Is this a bug, or is there a reason for this??