DEV Community

Zipporah
Zipporah

Posted on

Constants In Ruby

Today I learned that variables are always formatted in the 'snake case' like this :my_first_variable.

I also learned that constants are usually connected to a string for example: MY_FIRST_CONSTANT = 10. And once constants are assigned, they cannot be changed, meaning this constant is going to always be 10.

Also, I learned that classes and constants are similar.Classes are the way Ruby organizes."Objects are generally created by instantiating classes using the .new method".
For example,it looks like this:

Define the class

class Calculator
#...
end

Top comments (0)