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 flow alterations in Ruby −break statementnext statementredo statementretry statementLet's consider each of these one by one.break statementWhen a condition is True in Ruby, the break statement terminates a loop.ExampleConsider the code shown below.# break statement example itr = 1 while true if itr * 6 >= 35 ... Read More
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 to print any numbers that come after it. In such a case, we can use the break statement.Example 1Let's take an example and understand how the break statement works in Ruby. Consider the code shown below.# break statement in Ruby #!/usr/bin/ruby -w itr = 1 # while Loop ... Read More
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 extracted from the array.SyntaxThe syntax of the slice() function is shown below −res = Array.slice(x, y)Here, x and y denote the starting index and the ending index, respectively.Example 1Now that we know a little about the slice() function on arrays, let's take a couple of examples and see how to ... Read More
Sometimes we need to extract a portion of an array data and perform some operation on the extracted data. In Ruby, we can perform such operations with the help of the shift() function.The shift() function takes one argument, which is an index that is used to remove the first element from that index and return all the elements before it. If the index is somehow invalid, then it returns nil.SyntaxThe syntax of the shift() function is shown below −res = Array.shift(x)Here, the argument "x" denotes the starting index.Example 1Now that we know a little about the shift() function on arrays, ... Read More
This article guides you on what you should do to protect yourself if you think your system or device has been hacked. The focus of this article is on limiting the harm and containing the security incident.IP address is used by servers to send and receive data to and from your device. Nowadays, whether it is a financial institution or an informational website, each website with an online presence on the Internet needs a safe environment to exist—What may your IP address be used for, and how can you protect yourself from data breaches. Because this is a very prevalent ... Read More
Android is the most widely used operating system in the world. Android has been already installed on more than 3 billion devices, and the number is rising. There are a lot of things to like and prefer about Android. It is small and adaptable, and it works with anything from high-end smartphones to inexpensive phones under $100.Unfortunately, not everything in the Android world is perfect. While we doubt that it would convince you to jump ship and join Apple, it is something to keep in mind. We're referring to the large number of malicious apps discovered in the Google Play ... Read More
Computers slow down for a variety of reasons. Maybe you’ve unavoidably accumulated virtual trash when you download applications, install extensions, visit the web, create files, and fill your hard drive with multimedia, which will have an influence on your PC's performance. So, if you've been wondering, "Why is my computer so slow?" then go through this article to find out the causes and the easy steps you can take to speed things up.Why Do Computers Slow Down?Let's identify the most prominent causes that can slow down a computer −Excessive Number of Starting ProgramsNewly downloaded apps frequently try to sneak their ... Read More
Some computer viruses are very sneaky: you believe your device won’t get infected, but then your machine stops operating properly. Macro viruses are a sort of virus that can infect your device at any time. In this article, let's check how to avoid and eradicate Macro Viruses with specialized antivirus software.What are Macro Viruses?Macro viruses infect papers, spreadsheets, and other data files by inserting malicious code into macros. In July 1995, the first macro virus, Concept, was released, and since then, macro viruses have become increasingly popular.Because it's coded in a macro language, it's known as a Macro Virus. A ... Read More
Although a VPN and a VPS may sound similar, however, they are two distinct technologies with nothing to do with one another. A Virtual Private Server (VPS) is essentially a type of web hosting. Whereas, a Virtual Private Network (VPN) is a service and technology that allows you to stay entirely private and anonymous online. Despite the fact that they are entirely separate services, they are sometimes grouped together due to their names. It's really simple to get these two terms mixed up, especially if you're new to the Internet.What is a Virtual Private Server (VPS)?Before we can begin our ... Read More
Whether it's an enterprise, a political institution, a country, or even your own home, security is a key aspect. Computers, mobile devices, and the Internet are all confronting an increasing number of security threats.Computers and mobile phones have now been included to the list of a person's essential needs. We all rely on these gadgets for anything, from simple mathematical calculations to storing data, developing programs, interacting with the rest of the world, and so on.Virus assaults, data theft, data deletion, and hardware damages are among some security concerns. A Proactive and Defensive strategy to online security concerns is required ... Read More