Ruby Tutorial for Beginners!

Posts 15 of 5 · Page 1 of 1
Ruby Tutorial for Beginners!
Ruby

Hello! I'm rather new to this section of the forum and I've decided to start off my reputation on a good track!

So, here is my beginning tutorial to Ruby!

First we will write a hello world program which is the easiest thing to write in Ruby, in my opinion anyway.

Code:
print "Hello, World!"
The
Code:
print
command displays whatever is in between the
Code:
""
.

Pretty easy right? How about we add something more interesting.

Variables

In this section, I will teach you how to set and call variables in the easiest manner. Remember I will not make this a more challenging guide this guide is simply for the very beginning of Ruby.

Code:
print "Hello, what is your name?"
name = gets.chomp

print "Hello, #{name}."
So if you haven't already noticed, the program asks you for your name and says hello to you calling you by your name you typed into the console.

The
Code:
name = gets
basically assigns the variable
Code:
name
to whatever the user inputs.

The
Code:
.chomp
command eliminates random spaces which could screw up your beautiful formatting ;)

Okay, now this is where Ruby starts to look less like English.

The
Code:
#{ }
basically calls upon the variable that you specify in the middle.

If you typed out the code properly the code should output this

Code:
Hello, what is your name?Julian
Hello, Julian.
Thanks for reading! Hopefully more tutorials to come!
Where do I get this program I want to learn how to code?
Easy and interesting. Nice aproach to those who know nothing or remember nothing about this (I once started but quickly dropped)
Will try to read further into this.
Will wait for more tutorials of you!
Easy and interesting. Nice aproach to those who know nothing or remember nothing about this (I once started but quickly dropped)
Will try to read further into this.
Will wait for more tutorials of you!
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Need help?