[why] the when define a constant, the constant may already defined in required files, when execute the script, my throw warnings:
./answerback-email.rb:32: warning: already initialized constant SEND_MAIL_HOST ~/compass-ci/lib/constants.rb:11: warning: previous definition of SEND_MAIL_HOST was here ./answerback-email.rb:33: warning: already initialized constant SEND_MAIL_PORT ~/compass-ci/lib/constants.rb:12: warning: previous definition of SEND_MAIL_PORT was here
Signed-off-by: Luan Shengde shdluan@163.com --- container/assign-account/answerback-email.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/container/assign-account/answerback-email.rb b/container/assign-account/answerback-email.rb index a99306b..098561c 100755 --- a/container/assign-account/answerback-email.rb +++ b/container/assign-account/answerback-email.rb @@ -29,8 +29,8 @@ defaults = relevant_defaults(names)
JUMPER_HOST = defaults['JUMPER_HOST'] JUMPER_PORT = defaults['JUMPER_PORT'] || 29999 -SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || 'localhost' -SEND_MAIL_PORT = defaults['SEND_MAIL_PORT'] || 49000 +SEND_MAIL_HOST ||= defaults['SEND_MAIL_HOST'] || 'localhost' +SEND_MAIL_PORT ||= defaults['SEND_MAIL_PORT'] || 49000 LAB = defaults['lab'] TOOL_SERVER = 'z9'
On Tue, Jan 19, 2021 at 10:33:56AM +0800, Luan Shengde wrote:
[why] the when define a constant, the constant may already defined in required files, when execute the script, my throw warnings:
./answerback-email.rb:32: warning: already initialized constant SEND_MAIL_HOST ~/compass-ci/lib/constants.rb:11: warning: previous definition of SEND_MAIL_HOST was here ./answerback-email.rb:33: warning: already initialized constant SEND_MAIL_PORT ~/compass-ci/lib/constants.rb:12: warning: previous definition of SEND_MAIL_PORT was here
Signed-off-by: Luan Shengde shdluan@163.com
container/assign-account/answerback-email.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/container/assign-account/answerback-email.rb b/container/assign-account/answerback-email.rb index a99306b..098561c 100755 --- a/container/assign-account/answerback-email.rb +++ b/container/assign-account/answerback-email.rb @@ -29,8 +29,8 @@ defaults = relevant_defaults(names)
JUMPER_HOST = defaults['JUMPER_HOST'] JUMPER_PORT = defaults['JUMPER_PORT'] || 29999 -SEND_MAIL_HOST = defaults['SEND_MAIL_HOST'] || 'localhost' -SEND_MAIL_PORT = defaults['SEND_MAIL_PORT'] || 49000 +SEND_MAIL_HOST ||= defaults['SEND_MAIL_HOST'] || 'localhost' +SEND_MAIL_PORT ||= defaults['SEND_MAIL_PORT'] || 49000
the pattern "A = a || b" is nice than "A ||= a || b", why modify it ?
Thanks, Dewan
LAB = defaults['lab'] TOOL_SERVER = 'z9'
-- 2.23.0
+SEND_MAIL_HOST ||= defaults['SEND_MAIL_HOST'] || 'localhost' +SEND_MAIL_PORT ||= defaults['SEND_MAIL_PORT'] || 49000
the pattern "A = a || b" is nice than "A ||= a || b", why modify it ?
see the change log, this is for constant definition case you have defined the constant somewhere else, when you re-define it, it will throw wraning
Thanks Luan Shengde
Thanks, Dewan
LAB = defaults['lab'] TOOL_SERVER = 'z9'
-- 2.23.0