This has bothered me for a while, so I made a question on StackOverflow:

I’ve long been aware that “constants” in Ruby (i.e., variable names that are capitalized) aren’t really constant. Like other programming languages, a reference to an object is the only thing stored in the variable/constant. (Sidebar: Ruby does have the facility to “freeze” referenced objects from being modified, which as far as I know, isn’t an ability offered in many other languages.)

So here’s my question: when you re-assign a value into a constant, you get a warning like so:

> FOO = 'bar'
=> "bar"
> FOO = 'baz'
(irb):2: warning: already initialized constant FOO
=> "baz"

Is there a way to force Ruby to throw an exception instead of printing a warning?