What (of bad) can happen if I state a constant value using '||='?
I am using Ruby on Rails v3.0.9 and I would like to know what (of bad) can happen if I state a constant value as this:
MAX_LENGTH ||= 30
BTW: I am developing an "acts_as_something" plugin (in my application more than开发者_运维问答 one class "acts_as_something") and I must state constant values like above in order to not show\generate "warning messages" in the /.../log/apache2/error.log
(production mode) as the following:
warning: already initialized constant MAX_LENGTH
Warnings in general are never good. You might want to switch it to this:
unless (const_defined?(:MAX_LENGTH))
MAX_LENGTH = 30
end
精彩评论