Ruby

9 miniposts
Ruby

How to interpolate a Ruby Symbol

One tricky part in terms of its syntax, is the interpolation of a Ruby Symbol. This minipost aims to demonstrate Ruby Symbol interpolation and also how to add a space between two seperate words on a Ruby symbol declaration.

Ruby

How to update your rbenv version with git

This minipost will demonstrate how to update rbenv version when you have installed it through git to your system. To be more specific, we will update rbenv from version 1.1.0 to version 1.1.1 via git pull.

Ruby

How to update your rbenv ruby version

When you install rbenv with git to your machine, it does not update automatically all the new available ruby versions. Therefore, you need to update by git pulling the latest stable release. This minipost will demonstrate step-by-step how to configure your rbenv with the latest stable release of Ruby.

Ruby

What is the difference between clone and dup in Ruby

When you want to protect objects from being changed inside the methods you send them, Ruby offers some methods to preserve that original objects will not get altered in method calls. These methods are: dup and clone which are very similar with two differences.

Ruby

How to keep your irb session prompt and output shorter

While experimenting with code snippets on your irb (Interactive Ruby Interpreter) session, you might want to keep things clearer. This minipost demonstrates how to hide session returns and make irb prompt shorter allowing better focus on code execution.

Ruby

Different ways of printing in Ruby

There are three basic output methods in Ruby: print, puts and p. All these methods are used to output messages, results and valuable information during the execution of a Ruby program. However, there are some differences which are going to be demonstrated in this minipost.

Ruby

Avoid the use of unless conditional with an else clause in Ruby

In Ruby, there are three ways of negating conditions. The first one is the not keyword. The second one is with the negating ! (the bang operator of negation). The third and more natural sounding way of negating is the unless keyword. The keyword unless, express the exact same semantics as if not (expression) and if !(expression).