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.
- 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
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!).
- 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+/, " ")
if answer == "exArray" <- This means the correct response is "exArray"
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!
- 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!
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