Variables

Constants in Ruby

Used to declare a variable whose value is not meant to be changed.


Syntax
#constant name must start with a capital letter
CONSTANT_NAME = value

Notes

There are no true constants in Ruby. Variables declared as constants can be modified after assignment, but a warning is given by the compiler.


Example
PI = 3.14

Add to Slack

< Local Variable Declaration   |   Arrays >

© 2019 SyntaxDB. All Rights Reserved.