Tsallaka zuwa abun ciki
Justice Tech School

Constants, Globals and Special Variables

Constants start with a capital letter. Globals start with $ and should be avoided. Special values include __method__, $0, $PROGRAM_NAME and ENV for environment variables.

Example
PI = 3.14159
puts PI
puts ENV.fetch("HOME", "none").class
puts __method__.inspect
def who = __method__
puts who

Result

3.14159
String
nil
who

Exercise

Environment hash.

["HOME"]

Quiz Test

Which hash holds environment variables?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.