简体   繁体   中英

Can a mutator method modify a variable/object and return it?

Is it okay to write a mutator method that modifies a variable/object and returns a value? For example, a function implementing a sorting algorithm that returns a sorted array?

Would this be considered a mutator method?

尽管这不是编写变体的常见方法,但是只要您明确指出要返回更新后的值,就不会有任何问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM