Ruby Methods and Optional parameters

后端 未结 11 1614

I\'m playing with Ruby on Rails and I\'m trying to create a method with optional parameters. Apparently there are many ways to do it. I trying naming the optional parameters

11条回答
  •  不知归路
    2020-12-13 09:44

    In second approach, when you say,

    my_info2 "Bill", age: 28

    It will pass {age: 28}, and entire original default hash {age: 27, weight: 160, city: "New York"} will be overridden. That's why it does not show properly.

提交回复
热议问题