Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Mukul Latiyan
Page 20 of 37
What languages have been used to write Windows, Mac OS and Linux OS?
We know that an operating system is considered the backbone of any system that you may use. The three most common and widely used operating systems share things in common just as well as they share differences. While there are cases where one might outperform another, those cases and such scenarios are very rare.The most notable difference one can notice is how they store the files in their file structure, like in case of windows, it follows a directory structure to store the different kinds of files of the user, whereas the Mac OS file structure is known as MAC ...
Read MoreHow to Use Instance Variables in Ruby
In Ruby, there are four different types of variables that we can declare −Local VariablesInstance VariablesClass VariablesGlobal VariablesAn Instance variable has a name that starts with the @ symbol. It should be noted that the contents of an instance variable are only restricted to the object which itself refers to.An important point to note about the instance variable in Ruby is that, even if we have two separate objects that belong to the same class, we are allowed to have different values for their instance variables.Instance Variable Characteristics in RubyBefore checking how to use instance variables in Ruby, let's understand ...
Read MoreDifference between 'include' and 'extend' in Ruby
In Ruby, when we are using the include keyword, we are importing a module code, but we aren't allowed to access the methods of the imported modules with the class directly because it basically gets imported as a subclass for the superclass.On the other hand, when we are using the extend keyword in Ruby, we are importing the module code but the methods are imported as class methods. If we try to access the methods that we imported with the instance of the class, the compiler will throw an error.Now let's use these two keywords in a Ruby code to ...
Read MoreHow to use the "not" keyword in Ruby?
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 not keyword works like the "!" operator in Ruby, but the only difference between them is that the "!" operator has the highest precedence of all operators and the "not" operator has the lowest.SyntaxHere is the syntax of the not keyword in Rubynot expressionNow, let's take a couple of examples ...
Read MoreHow to use the "defined?" keyword in Ruby?
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 expression or the argument is not defined in Ruby.SyntaxThe syntax of the defined keyword in Ruby is given belowdefined? variable_nameNow, let's take a couple of examples to demonstrate how to use the defined keyword in Ruby.Example 1Consider the code shown below.# Declare the Variables programming = 2 ruby = programming ...
Read MoreHow to use the 'and' keyword in Ruby?
'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 in Ruby.SyntaxThe syntax of the and keyword is shown below.expression1 and expression2Let's use the and keyword in a Ruby code and see how it works.ExampleConsider the code shown below.variable1 = "sunshine" variable2 = "$un$h1ne" # Using and keyword if (variable1 == "sunshine" and variable2 == "$un$h1ne") puts "Learn ...
Read MoreUseful Methods from Numeric Class in Ruby
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 below −ExampleConsider the code shown below.num = 14 puts num.even? num = 19 puts num.even?OutputIt will produce the following output.true falsenumber.odd in RubyThis method is used when we want to check if a particular number is odd or not. Consider the code shown below −ExampleConsider the code shown below.num ...
Read MoreUseful Methods in Float Class in Ruby
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 want to return True, if two objects are equal.ExampleConsider the code shown below.puts 3.7 == 4 puts 3.7 == 3.7OutputIt will produce the following output.false trueabs Method in RubyThe abs method is used when we want to return the absolute value of a float.ExampleConsider the code shown below.puts (-50.56).abs puts ...
Read MoreHow to Read and Writes Files in Ruby
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 are different modes that one can use to do file handling in Ruby. These are −r = Read-only moder+ = Read-Write modew = Write-mode onlyw+ = Read-write modeAnd some more. These four mentioned modes are the most commonly used ones, when it comes to file handling in Ruby. In this article, ...
Read MoreExamples of String Functions in Ruby
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 Check Empty stringTo check if a string is empty, we use the size method and comparison operator.ExampleConsider the code shown below.str = "TutorialsPoint" puts str.size == 0OutputIt will produce the following output.false To Extract a Substring from StringTo extract a substring from a string, we will use square bracket notation.ExampleConsider ...
Read More