Newer
Older
7in7 / ruby / day1 / selfstudy.md
@x-way x-way on 19 Dec 2010 1 KB

Find:

Do:

  • Print the string "Hello, world." => puts "Hello, world."
  • For the string "Hello, Ruby." find the index of the word "Ruby." => "Hello, Ruby.".index("Ruby.")
  • Print your name ten times => (1..10).each{puts "Andreas"}
  • Print the string "This is sentence number 1." where the number 1 changes from 1 to 10 => (1..10).each{|i| puts "This is sentenc number #{i}"}
  • Run a Ruby program from a file => ruby file.rb
  • Bonus problem: if you're feeling the need for a little more, write a program that picks a random number. Let a player guess the number, telling the player whether the guess is too low or too high.