What's so bad about ref parameters?

后端 未结 12 670
隐瞒了意图╮
隐瞒了意图╮ 2021-01-11 09:49

I\'m faced with a situation that I think can only be solved by using a ref parameter. However, this will mean changing a method to always accept a ref parameter when I only

12条回答
  •  难免孤独
    2021-01-11 10:36

    Perhaps use an overloaded function for this 5% case and leave the other function as is.

    Unnecessary ref parameters can lead to bad design patterns, but if you have a specific need, there's no problem with doing this.

提交回复
热议问题