Ruby: Print Version String from Script

By Xah Lee. Date: . Last updated: .

Print version from the command line:

ruby -v

Print version from within a script:

# -*- coding: utf-8 -*-
# Ruby

p RUBY_VERSION # "2.3.7"

Printing version from script is a important technique to find out which version your script is running. Because, you might have several version installed, and and it's harder to find out in terminal, because there are aliases, links, path environment variables, etc effect which Ruby version will start when you type ruby in shell.

Ruby Version Release Dates

Ruby Version Release Dates

If you have a question, put $5 at patreon and message me.

  1. Ruby Basics
  2. Doc Lookup
  3. Print Version String
  4. What's RVM, Gem, Rake, Bundler, RDoc, ri, irb?

  1. Unicode 💎
  2. Quote String
  3. Quote Long String
  4. Format String
  5. String Operations
  6. True, False
  7. “if then else”
  8. for, while, Loop
  9. List
  10. Loop Thru List
  11. Hash Table
  12. Function Optional Parameter
  13. Map f to List
  14. Complex Numbers
  1. Intro to Reading Ruby Doc: What's M, C, ::, # ?
  2. Predefined Global Variables