Quantcast

Previous definition of was here.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Previous definition of was here.

butsan.yuriy

I have 2 warnings before output. What is the problem?

Hello = "Hello, guys!"
Hello2 = nil
Hello2 = Hello
puts Hello2
puts Hello


OUTPUT________________
Variables.rb:7: warning: already initialized constant Hello2
Variables.rb:5: warning: previous definition of Hello2 was here
Hello, guys!
Hello, guys!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8ddaca92-9942-4d8e-918a-a5a1acb6072b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Previous definition of was here.

Colin Law
On 7 May 2017 at 00:27,  <[hidden email]> wrote:

> I have 2 warnings before output. What is the problem?
>
> Hello = "Hello, guys!"
> Hello2 = nil
> Hello2 = Hello
> puts Hello2
> puts Hello
>
>
> OUTPUT________________
> Variables.rb:7: warning: already initialized constant Hello2
> Variables.rb:5: warning: previous definition of Hello2 was here

Variables that begin with a capital letter are assumed by ruby to be
constants, so you get a warning if you try to change the value.  Using
Rails it best to stick to the conventions, so variable names are of
the form name, another_name and so on.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLtvX37hLVViXLpR1bmYyp5swYDUjdKvz5T8wRTngnfP0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Previous definition of was here.

butsan.yuriy
Thank you a lot!

воскресенье, 7 мая 2017 г., 10:51:53 UTC+3 пользователь Colin Law написал:
On 7 May 2017 at 00:27,  <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="nuNDj0KcAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">butsan...@...> wrote:

> I have 2 warnings before output. What is the problem?
>
> Hello = "Hello, guys!"
> Hello2 = nil
> Hello2 = Hello
> puts Hello2
> puts Hello
>
>
> OUTPUT________________
> Variables.rb:7: warning: already initialized constant Hello2
> Variables.rb:5: warning: previous definition of Hello2 was here

Variables that begin with a capital letter are assumed by ruby to be
constants, so you get a warning if you try to change the value.  Using
Rails it best to stick to the conventions, so variable names are of
the form name, another_name and so on.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c506a0b4-1cc6-4300-b09e-7ea5eb5024aa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...