📜 ⬆️ ⬇️

Preface, first steps

Ruby is one of the youngest languages, but in Japan it has already managed to press such giants as Python and Perl. Ruby works on many platforms such as Linux, many Unix implementations, Windows 9x / 2000 / NT, MacOS, and many others.

Ruby
Ruby, got its name from the precious stone Rubin.

The language is very good in order to start learning programming from it. Ruby is also a free language, which frees us from any costs.
')
The book Ruby the Object-Oriented Scripting Language, immediately after the release became a bestseller. In recent years, many books have appeared on Ruby, unfortunately, not having a Russian translation.

Download Ruby for Windows, for example, here: One-Click Installer


Let's start with a simple!

Files containing programs in the Ruby language have the extension .rb

For example, in Windows, to launch the program, it is enough to save it in the root folder, open a command prompt and enter the command
ruby filename.rb


So, create the file hello_world.rb and write our first program:
puts "Hello World!"



Save and run.
ruby hello_world.rb


As a result of the program execution, the following phrase will be printed in the command window: Hello Worl!


Comments in Ruby.

In Ruby, there are several types of comments.
Single line comments look like this:
# This is a comment
puts "HabraHabr!"


Multiline like this:
= begin
Everything between the begin and end lines is a comment.
= end
puts "Hello HabraPeople!"



The first part is written by Korovkin Pavel , at the heart of the article, the knowledge gained at the Moscow State University of Arts. If the article finds its readers, a sequel will be written.

Sincerely.

Source: https://habr.com/ru/post/11003/


All Articles