Skip to content

Instantly share code, notes, and snippets.

@wyattdanger
Created December 28, 2010 17:42
Show Gist options
  • Save wyattdanger/757458 to your computer and use it in GitHub Desktop.
Save wyattdanger/757458 to your computer and use it in GitHub Desktop.
# Print the string "Hello, World"
puts "Hello, World"
# Find index of "Ruby" in "Hello, Ruby"
"Hello, Ruby".index "Ruby"
# Print your name ten time
10.times { puts "Stephen" }
# This is equivalent to the above one-liner
10.times do
puts "Stephen"
end
# Print string, "this is sentence number x" from 1 to 10
(1..10).each {|i| puts "This is sentence number #{i}." }
# Run a ruby script from the command line
# ruby day1.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment