Code Monkey home page Code Monkey logo

hello-world-ruby-001's Introduction

Your First Ruby Program - Hello World!

Overview

You're going to make a file that will print "Hello World!" to your terminal.

Objectives

  1. Create a new text file.
  2. Write syntactically valid code to produce "Hello World!"
  3. Running a ruby file.
  4. Running the learn gem.
  5. Submitting the Lab.

Video

MP4

Instructions

Step 1

The first step is to create a text file called hello_world.rb. The .rb file extension is a common convention for specifying the language of the file, in this case, Ruby. You can create a file by making a new file in your favorite text editor and saving it into this labs directory. Or you can type touch hello_world.rb within your terminal once you've navigate into this labs directory with cd. If you have Sublime Text and the Sublime Text symlink subl setup, you can also type subl . within this labs directory to open the entire directory in sublime (very useful).

Step 2

In the file hello_world.rb that you created, you need to write a single line of code that prints the string Hello World! to your terminal. Did you notice the method for printing in Ruby in another lab? It is short for "output string". It's the method puts. And remember how to make a string in Ruby? Just surround your text with "".

File: hello_world.rb

puts "Hello World!"

Step 3

Execute this file by typing ruby hello_world.rb into your terminal and pressing enter. The ruby part of that command tells your computer to use the Ruby interpreter when reading and executing the code in your file. The second part of the command, hello_world.rb is the path to the file you want to run.

You should see:

$ ruby hello_world.rb
Hello World!

Step 4

Confirm everything is working by running the learn command.

Step 5

Add, Commit and Push your code to GitHub and open a pull request and this lab is done, but your adventure in Ruby has only just begun!

Hello World History

Hello World! Art

Hello World! by Brian Kernighan, from Artsy's Algorythm Auction based on a 1974 Bell Laboratories internal memorandum by Brian Kernighan, Programming in C: A Tutorial, which contains the first known version.

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.