Skip to content
← Back to Community
Learn the Basics of Ruby! Interactive Program for Anyone New to Ruby :)
Profile icon
21Miya

If you're interested in learning the Ruby programming language, this program might help you out with the basics:

printing/putting, delaying code (sleep), variables, some math/methods (to int and to string), arrays, calling random integers, getting user input, loops, and if/elsif/else statements.

Other features:

  • Interactivity! The program asks the user for code after teaching topics to check if the user understands.
  • Tips & help! During any question, the user can input "help" or "h" instead of code in order to receive tips with the specific coding problem.
  • The program itself...is coded in Ruby! So if the user wants to see some Ruby in action, they can check out the IDE. Plus, I recently added comments within the IDE that are meant for the user to read. I highly suggest checking this out.
  • Not too much at once! Seeing a ton of code all at once (or even normal text) can be overwhelming, but this program goes at the user's own pace! Simply press the enter key when ready to move on.

So if you're looking for a new language--this is a sign to try out Ruby (my own preferred language)! Scroll down to the Repl and click run to start learning! :D

ruby(1)

Let me know if there's a topic in Ruby that you consider a "basic" that I should cover but didn't in this tutorial! And please leave an upvote if you used it at all or just like it!

If you're using Repl.it with light mode (default), the comments in the IDE will be a pale grey or light green (depending on if you're on desktop or mobile, I believe). If you're using Repl.it with dark mode, the comments in the IDE will be green. I explain a lot of things in the comments and it's also a great way to see Ruby color-coded and such.

Update as of September 28th, 2020

Hi everyone! I'm not sure if anyone will actually see this, but I wanted to give you guys an update since I continue to get emails about this post despite it being 2 years old (which is kinda cool, since I never expected so many people to find it helpful!).

  1. Unfortunately I don't check here often and therefore am unlikely to respond to comments anymore. However, if you're having trouble with a specific problem, I wanted to make sure everyone knows that you can simply look at the IDE, scroll to that problem, and see what input would be accepted!
  • Here's a sample from the code:
    answer = gets.chomp.gsub(/\s+/, " ")
    puts ""
    if answer == "exArray[7]" <- This means the correct response is "exArray[7]"
    puts "That's exactly right--great job!"
  • If you check through this and still believe something about my code is wrong or that your correct answer simply isn't accounted for despite being valid, feel free to let me know (but be specific about which part) so I can fix it for future users. Thank you!
  1. I am aware some of the explanations for how Ruby works are simplified. This is because this is for first-time Ruby coders or coders who simply need a refresh. This is not meant to teach you everything about Ruby, or make you an expert in Ruby!
Voters
Profile icon
suukki
Profile icon
KeiichiTakahash
Profile icon
ElGrandeDios
Profile icon
nadh44
Profile icon
Khraken
Profile icon
mbender88
Profile icon
johndoeeee
Profile icon
Akendri007
Profile icon
Gwencanaa
Profile icon
Pwickes
Comments
hotnewtop
Profile icon
Michaelmikey

What a great Idea I just started learning Ruby and this is well thought out and executed. Thank you.

Profile icon
DylanSTrans

How do you know what printed and/or if you are correct. [email protected]

Profile icon
Michaelmikey

@DylanSTrans What do you mean

Profile icon
ENOCKKASHOSI
Profile icon
Michaelmikey

@ENOCKKASHOSI Hello you can find me on the discord g4m3rm1k3 :)

Profile icon
hvciobanu

its not work

Profile icon
Laetitia020304

that was very interesting! Thank you so much!

Profile icon
KobeFF

Well thought out! I might try to make a tutorial myself. Best wishes!

Profile icon
shrutiNx

i'm confused please help me.

Profile icon
RajChatterjee1

its not too hard ya can do it

Profile icon
JayMacdonald06

@RajChatterjee1 it is really hard raj

Profile icon
BryenLackey

right here: "Oh, and one more thing before I move on--did you notice that there were two equal signs in the while statement? This is because in every type of statement that requires an end, equal signs must double up when used. That's just how it is in Ruby. Don't ask me why."

no, it is because you are checking a condition versus declaring a variable. it's pretty good otherwise though. great refresh for me thanks

Profile icon
BryenLackey

@BryenLackey it's like this in all languages, usually. java has it.

Profile icon
Papa199

i am so condused

Profile icon
Nitetime

I enjoyed this!

Profile icon
theangryepicbanana

You could probably use Regex for testing the answer input and a case statement instead of a bunch of elsif statements. Otherwise pretty good

Profile icon
21Miya

@theangryepicbanana Thank you for the feedback! I might not incorporate a case statement in this specific tutorial, but I'll definitely look into it for future projects.

Profile icon
theangryepicbanana

@21Miya That would be nice too, but I was talking about your actual code

Profile icon
21Miya

@theangryepicbanana I know you were talking about my code. What else would you be talking about? :o

Profile icon
TB07EC

@theangryepicbanana bro i totally agreee this gal has fake codes thinks she's so cool

Profile icon
xCoralNeox

Thanks for the tutorial! This was well thought out and it was a really good refresher :D

Profile icon
betwixtbetween

I am brand new to coding and starting with Ruby, and, while I had already learned all of these basics except arrays, this was fun and helpful--thank you!

Profile icon
Creeopman

cool

Profile icon
NZHacker808

There's so much hard work!

Profile icon
TB07EC

um this is not called coding not to be rude and this is not proper computer language either because your just putting in inproper franguances in FAKE coding language and no that isn't how to learn ruby.

Profile icon
21Miya

@TB07EC If I were you, I would have at least 1 project on my profile coded in Ruby before claiming it isn’t a language. Thanks!

Profile icon
KobeFF

@21Miya Lol savage /:>

Profile icon
StrayLove

this is coolio. and so fun too.

Profile icon
Zavexeon

@MaxZagar Hey there, please be kind.

Profile icon
JaredCharles1

5544548

Profile icon
HansPeter4

DEVICE_ID="2f3ad89fb02641668ba80b21d09c7474"
ACCOUNT_ID="5da534baee0648a683328af12660b688"
SECRET="RDVINZUP2UB3G2WVC3G3PIULNF7S2D2W"

Profile icon
jamesxli

elsif userInput == "shut up"
puts "that is not very nice of you to say."
XD
also great tutorial, this helped me a lot. i now know the basics of ruby! :D

Profile icon
lizzynett

I am a novice here

Profile icon
TomBlk

Hello wolrd

Profile icon
BunnyBunz

its not working

Profile icon
BunnyBunz

/run

Profile icon
anishcoder

just starting yeah shrutinx ya can do it!

Profile icon
TB07EC

she's just righting down a book basically that you can visually see and then you would say this is fun but this is not coding repl.it is for coding i would suggest going to a book club then repl.it if you want to write books

Profile icon
21Miya

@TB07EC Hiya! Ruby is literally a coding language, and I didn’t create Ruby itself so if you have issues with it then that isn’t really up to me. As for the text, yes, it is made informal (I didn’t always use 100% programming terminology) to make it easier for those new to coding to understand it. If you hate reading; in fact, it seems like you don’t know how to—then don’t use my program, it isn’t for you. Thanks for looking at my project! <3

Profile icon
TB07EC

@21Miya hi um didn't think of it that way I mean I once was also a person who didn't know coding at all and I agree this isn't for me when I was little I use to right like that tooo hey uh,sorry if i said something mean to u.:)

Profile icon
21Miya

@TB07EC Please don't say I don't write well when you cannot spell the word "write" itself. You clearly have no knowledge of the subject you are trying to talk about and your input is irrelevant and unhelpful. Have a nice day!

Profile icon
MaxZagar

I code super computers all day so this is like learning the alphabet again

Profile icon
21Miya

@MaxZagar Hi! If you are already proficient in this particular coding language then I do not suggest clicking a tutorial described as "basics" since it is clearly not for you. This is simple English--since you do not know what basic means, I will inform you that it means the foundations-only. Thank you for looking at my project! <3

Profile icon
JORDANSISNEY

@21Miya Lol savage

Profile icon
KobeFF
Profile icon
GametonGames

@MaxZagar Roasted

Profile icon
amysadler

hi

Profile icon
amysadler

hello

Profile icon
DavidBriggs1

dog-bone> bowl bark/ play_ pet. east-time zone: leash beast roof top {wires} brains. vote [Atari]
bite scar/ blue sky| tea. glass shattered life line [beer] substance
wise smart. sound true life. aspirin/pills; water party, fun day.

Profile icon
StormzzXD

How