Warning: already initialized constant TmpCert_as_text

Hi all,

I use this in a ‘loop do’:

validationcheck = OpenSSL::X509::Certificate
TmpCert_as_text = validationcheck.new(File.read(“certs.pem”)).to_text

and I get this warning message:

warning: already initialized constant TmpCert_as_text

How can I get rid of it?

bye and thanks in advance
Henry

Heinrich P. wrote:

Hi all,

I use this in a ‘loop do’:

validationcheck = OpenSSL::X509::Certificate
TmpCert_as_text = validationcheck.new(File.read(“certs.pem”)).to_text

and I get this warning message:

warning: already initialized constant TmpCert_as_text

How can I get rid of it?

bye and thanks in advance
Henry

Ruby treats a variable name that starts with an uppercase letter as a
constant. Use tmpcert_as_text instead.

Tim H. wrote:

Heinrich P. wrote:

Hi all,

I use this in a ‘loop do’:

validationcheck = OpenSSL::X509::Certificate
TmpCert_as_text = validationcheck.new(File.read(“certs.pem”)).to_text

and I get this warning message:

warning: already initialized constant TmpCert_as_text

How can I get rid of it?

bye and thanks in advance
Henry

Ruby treats a variable name that starts with an uppercase letter as a
constant. Use tmpcert_as_text instead.

Life is sometimes that easy - but you don’t recognize it :slight_smile:

Thx.

Perfect!!!

bye
Henry

In Ruby all variables that starts with capital letter are treated as
constants. But Ruby just give you warning if you assign new value to
constant. Just use small letters in variable names. In your case it
would be: tmp_cert_as_text. And don’t mix different styles for
variable names. Ruby programmers prefer to use underscored_names
rather than camelNames.


Rados³aw Bu³at

http://radarek.jogger.pl - mój blog