tutorial series

How To Code in Ruby
  • By Brian Hogan and Tony Tran

  • Ruby is a popular object-oriented programming language. You can use Ruby to write anything from simple scripts to complex web applications. Open your favorite text editor and follow these tutorials to start exploring Ruby.

    Published on June 30, 2017

    In this tutorial, you’ll set up a Ruby programming environment on your local macOS machine using Homebrew—a free and open-source package manager for macOS—and you’ll test your environment out by writing a simple Ruby program.

    Published on June 30, 2017

    This tutorial will go over how to set up a Ruby programming environment on your local Windows 10 machine using the command line. You’ll configure Bash on Windows, and then use the Ruby Version Manager—better known as RVM, a software platform built to manage multiple Ruby installations—to install the latest version of Ruby and its prerequisites. Then you’ll test your environment out by writing a simple Ruby program.

    Published on July 10, 2017 · Updated on July 10, 2017

    In this tutorial, you’ll set up a Ruby programming environment on your local Linux machine via the command line. Then you’ll test your environment out by writing a simple Ruby program. This tutorial explicitly covers the installation procedures for Ubuntu 16.04, but the general principles should apply to any Debian-based distribution.

    Published on June 30, 2017

    The “Hello, World!” program is a classic and time-honored tradition in computer programming. It’s a simple and complete first program for beginners, and it’s a good way to make sure your environment is properly configured. This tutorial will walk you through creating this program in Ruby.

    Published on October 26, 2017 · Updated on January 6, 2021

    IRB, short for Interactive Ruby, is a REPL (read-eval-print loop) which serves as a quick way to explore the Ruby programming language and try out code without creating a file. In this tutorial, you’ll use IRB to run some code, inspect its output, bring in external libraries, and customize your IRB session.

    Published on September 28, 2017

    Comments are lines in computer programs that are ignored by compilers and interpreters. You can use comments to make your programs easier for other programmers to understand by providing more context or explanation what each part of a program is doing. In this tutorial, we will look at how to use comments in Ruby programs to leave notes, as well as how to use them as a debugging tool.

    Published on October 6, 2017

    In this tutorial, you’ll learn about the most important data types native to Ruby: integers, floats, strings, symbols, arrays, and hashes. This is not an exhaustive investigation of data types, but it will help you become familiar with the options you have available to you in your programs.

    Published on July 24, 2017

    A string is a sequence of one or more characters that may consist of letters, numbers, or symbols. In this tutorial, you’ll learn how to work with strings in Ruby. You’ll create strings, display them on the screen, store them in variables, join multiple strings together, and learn how to handle special characters such as newlines, apostrophes, and double quotes.

    Published on October 17, 2017

    Ruby strings have many built-in methods that make it easy to modify and manipulate text, a common task in many programs. In this tutorial, you’ll use string methods to determine the length of a string, index and split strings to extract substrings, add and remove whitespace and other characters, change the case of characters in strings, and find and replace text. When you’re done, you’ll be able to incorporate these methods into your own programs.

    Published on October 6, 2017 · Updated on August 1, 2022

    An array is a data structure that represents a list of values, called elements. Arrays let you store multiple values in a single variable. This can condense and organize your code, making it more readable and maintainable. In this tutorial, you’ll create arrays, access the values they contain, add, modify, and remove elements in an array, and iterate through the elements in an array to solve more complex problems.

    Published on October 13, 2017 · Updated on September 22, 2019

    Arrays let you represent lists of data in your programs. Once you have data in an array, you can sort it, remove duplicates, reverse its order, extract sections of the array, or search through arrays for specific data. You can also convert an array to a string, transform one array of data into another, and roll up an array into a single value. In this tutorial, you’ll explore some of the most practical methods Ruby provides for working with data stored in arrays.

    Published on October 6, 2017 · Updated on August 5, 2022

    Ruby provides several methods for converting values from one data type to another. In this tutorial, you’ll convert strings to numbers, objects to strings, strings to arrays, and convert between strings and symbols.