Mukul Latiyan has Published 322 Answers

How to use the "or" keyword in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:45:00

In Ruby, we use the "or" keyword to return the logical difference between its two operands. In simple terms, we can say that a condition becomes True if both the operands are true."or" returns True if any one of the conditions/expressions is "true".It returns False only when all the conditions ... Read More

How to use the "not" keyword in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:39:24

In Ruby, we use the not keyword when we want to get an expression and then invert its Boolean value. In simple words, if an expression evaluates to True, then by using the not keyword, we will get False as the result of the expression.It can be said that the ... Read More

How to use the "defined?" keyword in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:37:13

Ruby provides a special keyword known as defined? that is used to determine if a particular object or data type is defined in Ruby or not.The defined? keyword will return a string describing its expression or argument, if the passed expression or argument is defined. It returns nil if the ... Read More

How to use the 'and' keyword in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:35:03

'and' Keyword in RubyIn Ruby, we use the "and" keyword to return True if both the operands are true, and False if one or more of the operands is false. It should be noted that the and keyword is equivalent to the && logical operator, but it has lower precedence ... Read More

How to invoke methods in Ruby?

Mukul Latiyan

Mukul Latiyan

Updated on 12-Apr-2022 08:32:45

Methods in Ruby, as in other programming languages, bundle one or more repeatable statements into a single unit. Method names in Ruby should begin with a lowercase letter. If you begin a method name with an uppercase letter, Ruby might think that it is a constant and hence can parse ... Read More

Useful Methods from Numeric Class in Ruby

Mukul Latiyan

Mukul Latiyan

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

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

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

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

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

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

Advertisements