Mukul Latiyan has Published 474 Articles

Transpose() function in Ruby Programming

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 11:12:23

291 Views

The transpose function in Ruby is mainly used to return the transpose of an array or a matrix.Syntaxarray.transposeOrMatrix.transposeLet's take a couple of examples of the transpose function on array first and then on matrices.Example 1Consider the code shown below# transpose() in array # array declaration first_arr = [[18, 22], [33, ... Read More

Array push(), pop() and clear() functions in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 11:07:49

856 Views

The most widely used functions in Ruby when it comes to arrays are push(), pop(), and clear() functions. These functions are used when we want to enter, take out and clear the array data, respectively. In this article, we will learn about all these functions one by one.push() FunctionThe push ... Read More

String reverse vs reverse! function in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 11:02:01

366 Views

In Ruby, we have two functions available to us in case we want to reverse the contents of a string. These two functions are reverse and reverse!. While both of them are used to reverse the string, the only difference between them is that the reverse function reverses the string ... Read More

How to push and pop elements in a queue in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 10:55:33

238 Views

In this article, we will learn how to push (insert) and pop (remove) elements in a queue in Ruby.In Ruby, we can insert elements into a queue with the help of the push function. The syntax of the push function is shown below.queueName.push(element)Notice that the above syntax accepts one argument, ... Read More

Hash select() and select!() methods in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 10:46:50

1K+ Views

In Ruby, we make use of the select() method when we want to find the array from the hash based on the condition and we make use of the select!() method when we want to check whether the array from the hash is present or not.Let's explore a few examples ... Read More

How to use global variables in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 10:42:44

4K+ Views

Global variables have a global scope and they can be accessed from anywhere in a program. Assignments to global variables can be made from anywhere in the program. Global variables are always prefixed with a dollar sign.It is necessary to define a global variable to have a variable that is ... Read More

How does Recursion work in Ruby Programming?

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 10:39:32

282 Views

A function that calls itself directly or indirectly is called a recursive function, and the corresponding function is referred to as a recursive function. Recursion makes the process easier and it definitely reduces the compilation time.We will try to understand the concept of recursion in Ruby with the help of ... Read More

Yield keyword in Ruby Programming

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 10:33:05

402 Views

There are often cases where we would want to execute a normal expression multiple times inside a method but without having to repeat the same expression again and again. With the yield keyword, we can do the same.We can also pass arguments to the yield keyword and get values in return ... Read More

True, False and Nil in Ruby Programming

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 10:29:39

249 Views

We know that everything in Ruby is treated as an object, and so the true, false and nil as well. They are built-in types that Ruby provides to do different conditional checks and more. In this article, we will explore different examples of the true, false and nil data types ... Read More

Static Members in Ruby Programming

Mukul Latiyan

Mukul Latiyan

Updated on 25-Jan-2022 10:25:26

2K+ Views

Static Members in Ruby are declared with the help of the class. Since Ruby doesn't provide a reserved keyword such as static, when we make use of the class variable, then we create a static variable and then we can declare a method of that class in which the static ... Read More

Advertisements