Beyond Hello World
In the previous chapter, we learned how to run (or execute) Ruby code. However, we only focused on the syntax and not the usefulness of the code. The famous Hello World script we write in any language is, by itself, useless, at least from a practical sense. So, let’s start learning how to use some tools to give our scripts a little bit of usefulness.
One useful tool in any language is having a way to verify the version of the programming language that we are currently using. Once we obtain the version, we can stop the execution if the version we are using is incorrect. So, our first step is to get the current Ruby version. Let’s create a file called version_verification.rb
with the following code:
# version_verification.rb puts "We are running Ruby version #{RUBY_VERSION}"
We can run this script on our shell by typing the following command:
ruby version_verifications.rb
It should output something similar to this:
We are running...