Is it acceptable having parameter in class constructor?

后端 未结 3 1030
感情败类
感情败类 2021-01-13 06:33

a rubygem I\'m writing and that is useful for counting word occurrences in a text, I choose to put 3 parameters in class constructor.

The code is working, but I want

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-13 07:10

    I dont know how it is in Ruby, but in other languages you usually put those arguments in the constructor signature that are needed to initialize the object into a valid state. All other state can be set through setters.

提交回复
热议问题