All pastes #935544 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-03-09 18:45 UTC
rendered paste body
#!/usr/bin/ruby

foreignHello = {
        'english '      => 'hello',
        'polynesian '   => 'aloha',
        'spanish '      => 'hola',
        'italian '      => 'caio',
        'dutch '        => 'hallo'
}

if !ARGV[0]
        puts "ruby script to demonstrate control structures and arrays"
        puts "usage: ./ruby1.rb <number of times to print hello>"
else
        max=ARGV[0].to_i
        puts "method #1 - using .times"
        (max).times { puts "hello" }
        foreignHello.each do |language| |word|
                puts "Hello in #{language} #{word}"
        end
        puts "Now enter the word 'hello' or 'hi' to exit this!"
        while STDIN.gets
                if /hello|hi/
                        puts "Thank you for playing!"
                        exit
                end
        end
end