Named parameters in Ruby don't work? [duplicate]
问题 This question already has answers here : No named parameters in Ruby? (4 answers) Closed 5 years ago . I wonder why named parameters don't work as I expect. def my_method(var1, var2 = 1, var3 = 10) puts var1, var2, var3 end my_method(999, var3 = 123) The output 999 123 10 instead of (at least, as I guess should be): 999 1 123 So, what should I do to use named parameters? P.S. When I use the hash, it's not what I'm looking for yet: def my_method(var1, vars = {var2: 1, var3: 10} ) puts var1,