Book Image

Comprehensive Ruby Programming

By : Jordan Hudgens
Book Image

Comprehensive Ruby Programming

By: Jordan Hudgens

Overview of this book

Ruby is a powerful, general-purpose programming language that can be applied to any task. Whether you are an experienced developer who wants to learn a new language or you are new to programming, this book is your comprehensive Ruby coding guide. Starting with the foundational principles, such as syntax, and scaling up to advanced topics such as big data analysis, this book will give you all of the tools you need to be a professional Ruby developer. A few of the key topics are: object-oriented programming, built-in Ruby methods, core programming skills, and an introduction to the Ruby on Rails and Sinatra web frameworks. You will also build 10 practical Ruby programs. Created by an experienced Ruby developer, this book has been written to ensure it focuses on the skills you will need to be a professional Ruby developer. After you have read this book, you will be ready to start building real-world Ruby projects.
Table of Contents (20 chapters)

Arithmetic order of operations

When using arithmetic operators, it's important to understand the order of operations, as the compiler uses a specific format to determine this order.

So, what does this order mean for a problem/equation?

Let's say that we need to run an equation with all these operators, but in a different order. For example: 5 + 15 * 20 - 2 / 6 ** 3 - (3 + 1).

In the preceding problem, we have all the six operations included. If we run this code, it gives a value of 301.

To break it down, the compiler first looked for the parentheses, so it computed the value (3+1), which is 4. Then, it handled the exponent 6**3, which is 216. Next is multiplication, so 15 * 20 is 300. Now, for division, 2/216 will be equal to 0 (it's not really zero, but we'll discuss this in the next section). Next, it focuses on addition, 5 + 300 which equals 305. And lastly...