Ruby Language Constants Modify a Constant

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

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".



Got any Ruby Language Question?