Coder Social home page Coder Social logo

irb-readme's Introduction

Introduction to IRB

Objectives

  1. Describe IRB and why it's useful when programming.
  2. Distinguish IRB from your terminal and other files.
  3. Access and exit IRB via your terminal.
  4. Execute commands in IRB.

What is IRB?

IRB stands for "Interactive Ruby." It's a Ruby shell or REPL. REPL stands for read–eval–print loop. It is a simple, interactive computer programming environment that takes user inputs (such as, in our case, snippets of Ruby code), evaluates them, and returns the result to the user. IRB is run by your computer's terminal.

Reminder: The term 'terminal' refers to the program we use to communicate with our computer via text input. We can type commands one by one into the terminal and it will return responses, similar to the way people used computers before graphical user interfaces.

You can think of it as your Ruby playground or execution environment. You can open it up, insert code and execute it to see that code's return value.

What isn't IRB?

IRB is not a file where you save your work. Any coding you do in the IRB console in your terminal will not get saved anywhere. It only exists temporarily. IRB is for testing, playing, manipulating your code so that you understand it better and solve problems with it.

How do you use it?

IRB allows you to execute ruby in the terminal and you're going to get comfortable using it to test and better understand your Ruby code. To access IRB, just type irb in the terminal.

IRB allows you to do anything you can do in a Ruby file. For instance, you can do math, get the time by typing Time.now, or print text to the screen.

Instructions

  1. Open up your terminal.

    • If Sandbox is enabled, on this lesson's Learn page, you should see a 'Sandbox' button that will open Learn's in-browser IDE. The terminal is the at the bottom of the IDE (check this page out for more information)
    • If you do not have Sandbox, or are not sure how to access the terminal on your computer, you can also go to repl.it and create a Ruby based Repl to follow along. Repl.it, just like Sandbox, provides a simulated terminal in the browser that is ready to receive Ruby commands.
  1. In the terminal, type irb and hit return (if you're using Repl.it, you can skip this as the terminal is already set to read Ruby).

  2. Now that you've started IRB, type the commands below to see how it works! Type each of the following lines into the IRB shell and press enter.

  • Time.now
  • 255 / 5
  • 9 ** 2
  • puts "hello world"
  1. To leave IRB, type the exit command - this will get you back to your command line.

irb-readme's People

Contributors

ahimmelstoss avatar annjohn avatar arelenglish avatar aviflombaum avatar awesomescot avatar deniznida avatar dfenjves avatar fislabstest avatar fs-lms-test-bot avatar kthffmn avatar lizbur10 avatar maxwellbenton avatar ruthmesfun avatar sarogers avatar sophiedebenedetto avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

irb-readme's Issues

Bug

The video is bugged on chrome browser, but seems to work fine in safari.

Lesson video unavailable

Thanks for raising this issue! Future learners thank you for your diligence. In
order to help the curriculum team address the problem, please use this template
to submit your feedback. We'll work on addressing the issue as soon as we can.

Please fill out as much of the information below as you can (it's ok if you
don't fill out every section). The more context we have, the easier it will be
to fix your issue!

Note: you should only raise issues related to the contents of this lesson.
If you have questions about your code or need help troubleshooting, reach out to
an instructor/your peers.


Link to Canvas

https://learning.flatironschool.com/courses/4537/pages/intro-to-irb?module_item_id=262312

What should be changed?

The video is unavailable

Additional context

Add any other context about the problem here.
intro irb video unavailable

Terminal Lag Issue

Issue: Whenever I type in the terminal, at normal typing speed, a few characters get gobbled. There's lag in the console pointer, so I related this to that.
Screenshot of lag aftermath by Learn.co user @wendingp: Screenshot

User unable to open lab -ubuntu

Hi, github username farmerbot24 is unable to open this lab. It appears greyed out, even after following the steps here: https://github.com/flatiron-labs/learn-support/blob/master/learn_expert_nitrous_support.md

He says he has been using Windows and switching to ubuntu. Question is open until we have a solution for him: https://learn.co/tracks/intro-to-ruby-development/ruby-basics/debugging/intro-to-irb?batch_id=294&question_uid=q-86f762bd-e25e-452d-9396-a0ec918d3879&track_id=12307

Clarify that IRB is only a sandbox

Students often get confused and think that irb is the program they are coding in, as opposed to the file where they save their work. This readme should explicitly state that IRB is for testing only and that once they leave IRB their work will not be saved.

Instruction to open terminal

For the "interactive Ruby Shell" lesson, in the instructions, it says the following: "Open up your terminal. (If you do not have a terminal on your computer you can use repl.it)." What a terminal is on your computer or how to open one on repl.it is not explained and so confusing. I had to use the ask a question feature to figure this out. I suggest giving more clear instructions here. For example if you use repl.it, you will need to open a new ruby file type. Then here you don't need to type "irb" as step 2 instructs. I think that is only for the terminal. In repl.it it is already in irb.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.