Join Kevin Skoglund for an in-depth discussion in this video Constants, part of Ruby Essential Training.
In this movie, I want to talk about the Ruby object-type constants.…Now we don't use constants very often in Ruby at all, but it still is helpful to…understand them for couple of reasons, which we will see in a moment.…It's fitting that we are going close out with them because constants work a…lot like variables.…They are not true objects in Ruby, they are a part of the language construct and…they point the objects the same way that variables do.…The difference is that a constant is constant.…It should stay the same.…A variable will change over time.…So x=1, x+=1, now x=2. It's variable.…
A constant should stay the same.…Only in Ruby, it's not necessarily the case. Let's see.…We will open up irb.…We have already seen the way that we specify a variable name like test = 1, right?…That's a simple variable name.…Well, the way we want to specify constant names is with all capitals.…TEST equals, let's say, 2.…Two different things to return two different values.…The first is a variable, the second is a constant.…
- Using Ruby in the Interactive Ruby Shell and in standalone scripts
- Learning to write custom code blocks to find, merge, and sort
- Using modules for namespacing or as mix-ins
- Reading from and writing to files
- Creating a full Ruby project from start to finish
Skill Level Beginner
1. Getting Started with Ruby
2. Ruby Object Types
3. Control Structures
4. Code Blocks
8. Working with Files
9. Ruby Project: Creating the Food Finder
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.