Ruby Language Modify a Constant


Example

MY_CONSTANT = "Hello, world"
MY_CONSTANT = "Hullo, world"

The above code results in a warning, because you should be using variables if you want to change their values. However it is possible to change one letter at a time in a constant without a warning, like this:

MY_CONSTANT = "Hello, world"
MY_CONSTANT[1] = "u"

Now, after changing the second letter of MY_CONSTANT, it becomes "Hullo, world".