Comparing Basic Ruby Syntax to PHP
Running scripts in PHP and Ruby is similar, though each language has its peculiarities. Similarly, both Ruby’s and PHP’s syntax can be strangely similar at times, as we saw in Chapter 1. However, if we are serious about becoming Ruby programmers, we will need to learn both the differences and the enhancements that Ruby brings to the table.
Let’s embark on this journey and start creating, executing, and debugging our own Ruby scripts with the resources that we already have from knowing PHP, and see Ruby’s language improvements over other languages. We’ll not only think in Ruby but program in “the Ruby way” too.
So, in this chapter, we will cover the following topics:
- Running Ruby code from the command line
- Exploring types of variables
- Using conditional statements
- Repeating code with loops
- Using Ruby language enhancements