Working with Strings in Ruby

Similar Posts

  • Regular Expressions

    Regular Expressions, often called RegEx, is a sequence of characters that defines a search pattern to run against another string of data. This is often used to perform a find and replace or check for validation. Different languages apply regular expressions differently. The strictest use the full range of special characters and commands, while others…

  • Ruby Arrays and Hashes

    In Ruby, an array is an ordered collection of objects, which can hold multiple data types, including numbers, strings, other arrays, or even objects. Of the languages we’ve looked at, it is most similar to lists in Python, where you can store dynamic types, and they are dynamically sized. There are a couple of ways…

  • Repetition with Ruby

    The Ruby method each allows you to iterate over a list of items. This is essentially a for-each style of loop and is like JavaScript’s each method. Notice that the iterative value is placed inside of two pipe (|) characters. You don’t have to put everything on one line. In fact, you can’t if you have multiple…

  • Installing Ruby

    Installing Ruby is relatively simple. There is an install page as part of the Ruby documentation: https://www.ruby-lang.org/en/documentation/installation/ While they would prefer you to have a Unix, or Unix like environment, you can scroll down to find the best way to install this language runtime software. I personally went to the Ruby Installers section of the…

  • Basic Logic in Ruby

    In Ruby, you’ll find that all of the standard logic operators that most languages have, are supported. Symbol Meaning < Less than > Greater than == Equals != Not equals >= Greater OR equal to <= Less OR equal to Conditionals Of course, conditionals such as an if statement are also possible within Ruby. Similar…

  • Classes in Ruby

    Classes do not have to be in a separate file as you can see from the file below. Let’s look at a class, then break it down. Class Definition As with most languages, you use class to define your class definition, and class names typically start with a capital letter. As with conditions, and other…