Following code:
class Test
attr_reader :args
def initialize(arg1={}, arg2: 'value2')
@args = [arg1, arg2]
end
end
t = Test.new({key1: 'value1'})
puts t.args
I've expected to get printed out array with content [{key1: 'value1'}, 'value2']
but I'm getting:
test.rb:11:in `new': unknown keywords: val1, val2 (ArgumentError)
from test.rb:11:in `<main>'
To be more strange, with the same testing class invoked with {val1: 'value', val2: 'value2'}, arg2: 1)
as arguments i'm getting output: {:val1=>"value", :val2=>"value2"}
Where is the source of this behaviour, i'm missing something or it's a bug? Ruby versions 2.1.1 and 2.1.2 was tested.