03/04/2024, 12:11 Getting Started with Ruby: A Comprehensive Tutorial for Beginners
The Definitive Ruby Tutorial
For Complete Beginners
In this Ruby tutorial you'll learn everything you need to know
to get started learning this fun programming language so you
can create your own Ruby programs & do amazing things!
Ruby is an object-oriented language (more about that later) that
is easy to use & open source. It is widely used for web
applications, all kinds of scripts, and other interesting projects.
The Best Way To Learn Ruby
If you have decided to learn Ruby & become a Ruby developer then
you’re in the right place.
You’ve a lot of learning ahead of you, but don’t let that stop you from
getting started.
Learning is a beautiful thing
[Link] 3/10
03/04/2024, 12:11 Getting Started with Ruby: A Comprehensive Tutorial for Beginners
Learning is a beautiful thing.
Now:
Where do you begin?
You should start by learning the core programming concepts.
Things like:
Variables
Data structures
Conditional statements
You’ll find a lot of new words in your journey, don’t worry about that,
you’ll learn along the way.
You also need to understand that a programming language is a formal
language.
What does that mean?
In English, if I make a grammar mistake there is a pretty good chance
you can still understand me.
But if you make that kind mistake in Ruby, or any other programming
language, you’re going to get an error.
[Link] 4/10
03/04/2024, 12:11 Getting Started with Ruby: A Comprehensive Tutorial for Beginners
It’s fine, nothing is going to blow up…
But you’ve to understand the rules of the language, then apply them
correctly.
I’m telling you this is because I don’t want you to give up early if you’re
seeing a lot of error messages & if things don’t make a lot of sense.
It’s normal:
You are learning something new & it’s going to take some time
until it starts to sink in!
One of the keys is repetition.
Work on every concept until you understand how it’s useful in the big
picture, how to use it, how to explain it to other people.
This Ruby tutorial helps you learn step-by-step, so don’t skip steps.
Invest as much time as you need, have patience.
You can do this!
Let’s get started with the first step…
How to Download & Install
[Link] 5/10
How to Download & Install
03/04/2024, 12:11 Getting Started with Ruby: A Comprehensive Tutorial for Beginners
Ruby
If you are using Windows you want to go to this site to download Ruby:
[Link]
You want the recommended version (it’s in bold text), which at the time
of this writing is Ruby+Devkit 3.2.2-1 (x64) .
Just download & install it like any other program.
If no errors appear then you have Ruby installed on your computer!
Now to start writing your Ruby programs you will need to open a
terminal
[Link] 6/10
03/04/2024, 12:11 Getting Started with Ruby: A Comprehensive Tutorial for Beginners
terminal.
To do that open the windows menu & type [Link] .
Then press enter.
It will look something like this:
At this point you should be able to type ruby -v inside this window,
press enter, then you should see the current version of Ruby printed on
your screen. This means you are ready to start writing Ruby code.
Ruby Setup For Linux & Mac
Users
[Link] 7/10
03/04/2024, 12:11 Getting Started with Ruby: A Comprehensive Tutorial for Beginners
If you are on Linux or MacOS then you probably already have Ruby
installed.
You can confirm this by opening a terminal (search for “terminal” in
your menu), then typing ruby -v .
This should print your Ruby version.
Like this:
1. ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-
linux]
If you don’t see a Ruby version then refer to this site for more details on
how to install Ruby for your particular Linux version or Mac.
Let’s Write Some Code!
Now that you are all set up, I want you to open irb .
This is a Ruby program that allows you to type Ruby code & see the
results right away.
It’s a great way to practice & learn about Ruby.
To open irb you have to type the word irb inside that black
[Link] 8/10
03/04/2024, 12:11 Getting Started with Ruby: A Comprehensive Tutorial for Beginners
terminal window I had you open before.
Press enter.
Then you should see something like this:
1. irb(main):001:0>
Start by typing this into irb :
1. 5 + 5
Then press enter.
You’ll see the result of this operation.
“But I can do that with a calculator program!”
Of course.
The point of this is to get you used to typing inside the terminal
window.
And you’re going to be using numbers a lot inside your Ruby programs:
As data (price, age, year, etc.)
To count things
[Link] 9/10