Constants or class variables in ruby?

后端 未结 5 1898
闹比i
闹比i 2020-12-30 18:37

I\'ve been programming in Ruby for a few months now, and I\'m wondering when it is appropriate to use constants over class variables and vice versa. (I\'m working in Rails,

5条回答
  •  清歌不尽
    2020-12-30 19:09

    The main thing is that by using the CONSTANT notation, you're making it clear to the reader. the lower case, frozen string gives the impression is might be settable, forcing someone to go back and read the RDoc.

提交回复
热议问题