Other Pages


Input And Output

Input and Output

Terminal I/O

LAB: Hello, friend!

  1. Open hello.rb in your text editor
  2. Change it to contain the following code:

    puts "What is your name?"
    name = gets
    puts "Hello, " + name + "!"
  3. Save the file and switch back to the terminal

  4. Run the program using ruby hello.rb

  5. Type in your name and press the RETURN (or ENTER) key

What happens? Is this what you expected?



Let's fix this

The newline character

Strip it

LAB: fixing Hello, Friend

LAB: Capitalization

LAB: Crazy Name

LAB: Full Name


You just wrote a program!

You are now officially a coder. HIGH FIVE!

Lab: Name Length