Learn Ruby
Variables
5.7
Lesson

Variable assignment is not working

When we run this code we will get an error.

We are an getting error because 1 can’t be a variable. In Ruby a variable must start with a lowercase letter or with an underscore.

Here if we use a1 then that would work. Since a variable can start with an underscore _hello is also a valid variable name.