+ 2
Capital letter
why can't variable names begin with a capital letter?
3 Respuestas
+ 7
Variables that start with a capital letter are automatically constants, e.g.
The following code will be executed successfully:
x = 8
puts x #prints 8
x = 28
puts x #prints 28
But the following code causes warnings:
Ax = 8
puts Ax #prints 8
Ax = 28 #warning: already initialized constant Ax
puts Ax #prints 28, but displays a warning
Despite the fact that Ruby does not prohibit changing the constants, it is bad practice.
+ 3
good answer!
0
declaring variables by capital format leads to constants.