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
command displays whatever is in between the
.
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
basically assigns the variable
to whatever the user inputs.
The
command eliminates random spaces which could screw up your beautiful formatting ;)
Okay, now this is where Ruby starts to look less like English.
The
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!