18. Mixin for the Win


#1




The code doesn't behave incorrectly but I'm wondering why the warning shows up if I run it twice?


module Languages
  FAVE = "Ruby"  # This is what you typed before, right? :D
end

Throws "(ruby):1: warning: already initialized constant FAVE"

if I hit ctrl-enter twice. But shouldn't constants be cleared each time we run the script? I mean, we can use remove_const(:FAVE) but why should we have to? Constants in other languages don't show this behavior. At least not as I understand them. It seems that if someone unknowingly runs another script, they'll throw this error, and the downsides outweigh the benefits for programming, nuisance warning errors, etc.

I sense I'm missing a big concept here. What is it?

Thanks!


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.