Mukul Latiyan has Published 474 Articles

Useful Methods from Numeric Class in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:30:09

198 Views

There are several methods in Ruby that can be used on numbers. In this article, we will explore some of these useful methods and how to use them.number.even in RubyThis method is used when we want to check if a particular number is even or not. Consider the code shown ... Read More

Useful Methods in Float Class in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:26:02

227 Views

The Float class in Ruby is a subclass of the Numeric class. Its objects are the representations of real numbers, using the native architecture representation of floating-point numbers.Let's consider the different methods that are available in the float class in Ruby.== Method in RubyThe == method is used when we ... Read More

How to Read and Writes Files in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:22:01

4K+ Views

Ruby provides us with different methods that we can use to handle files. In simple terms, file handling involves different processes such as creating a new file, reading the contents present in a file, writing some content to a file, appending content to a file, deleting a file and more.There ... Read More

How to Handle Exceptions in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:05:57

115 Views

Exceptions in programming are errors that occur at runtime. They are hard to handle in an effective manner, but it is important to handle them, else they halt the program execution.Some of the common exceptions that one can encounter are −trying to open a file that is not there, dividing ... Read More

Examples of String Functions in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 07:56:32

272 Views

In this article, we will explore some useful string functions in Ruby that are widely used to format data.Get the Length of the StringTo find the length of the string, we will use the size method.ExampleConsider the code shown below.str = "TutorialsPoint" puts str.sizeOutputIt will produce the following output.14 To ... Read More

How Does Encapsulation Work in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 07:53:34

966 Views

Encapsulation is the ability to wrap the data into a single unit. In simple terms, it's a mechanism to wrap data and the code that manipulates the data. In Ruby, we can achieve encapsulation with the help of classes.Let's consider a very simple example where we will implement encapsulation.Example 1Consider ... Read More

How to implement Data Abstraction in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 07:48:08

883 Views

Abstraction is an object-oriented programming concept, where the essential attributes of something are shown and all the unnecessary ones are hidden. With this approach, one can hide the implementation details and provide only the important interface.A very good example of abstraction is your car. It's a great example of abstraction. ... Read More

Control flow alterations in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 07:43:48

187 Views

In addition to loops, conditionals, and iterators, Ruby has some statements that are used to change the control flow in a program. In other words, these statements are pieces of code that execute one after the other until a condition is met.In this article, we will explore the following control ... Read More

How to use the 'break' and 'next' statements in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 07:19:38

1K+ Views

break Statement in RubyIn Ruby, we use the break statement in order to make sure that we exit a certain loop after a condition. For example, suppose we want to print the numbers from 1 to 10, but once we hit the number 5, we just don't want the loop ... Read More

Array slice function in Ruby

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 07:14:56

1K+ Views

Sometimes we may want to exact a portion from an array data and perform some operation on it. In Ruby, we can do that with the help of the slice() function that takes two arguments, both of them indices, that are used to define a subsequence which then can be ... Read More

Advertisements