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 key (also called Enter)

What happens? Is this what you expected?

Yikes!

Breathe

Let's fix this

The newline character

Strip it

LAB: fixing Hello, Friend

LAB: Capitalization

LAB: Crazy Name

LAB: Full Name

CONGRATULATIONS!

You just wrote a program!

You are now officially a coder. HIGH FIVE!

Lab: Name Length

Next Lesson   Previous Lesson

Outline

[menu]

/