Ruby on Rails 5.0. For Autodidacts

                    Introduction


This book requires basic knowledge of HTML, plus the reader - you, in other words - should also have a basic understanding of programming.


The beginning of this chapter is going to be a bit boring. Bear with me. It’s worth it.


It is easy to program in Ruby, but Ruby is not a simple language.” ~ Yukihiro Matsumoto


This chapter is a tightrope walk between oversimplification and a degree of detail that is unnecessary for a Rails newbie. After all, the objective is not becoming a Ruby guru, but understanding Ruby on Rails.


I am going to elaborate on the most important points. The rest is then up to you. If you would like to know more about Ruby, then I recommend the book "The Ruby Programming Language" by David Flanagan and Yukihiro Matsumoto.


The command ruby -v will print the current running Ruby version: $ ruby -v ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin15]


Hello World

Ruby is a scripting language. So it is not compiled and then executed, but read by an interpreter and then processed line by line.


A simple Ruby program hello-world.rb consist of the following line: Listing 1. hello-world.rb puts 'Hello World!'


Use your favorite editor to open a new file with the filename hello-world.rb and insert the above line into it. You can then execute this Ruby program in the command line as follows: $ ruby hello-world.rb


Hello World!

A program line in a Ruby program does not have to end with a semicolon.


The Ruby interpreter is even so intelligent that it recognizes if a program line was split over two or more lines for the sake of readability.


I will spare you the corresponding examples and am only mentioning this so you don’t say or think later, "is it okay like this?"


Indenting code is also not necessary. But it does make it much easier to read for human beings!

Customer Reviews