Skip to content

Instantly share code, notes, and snippets.

Created June 14, 2012 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/2931188 to your computer and use it in GitHub Desktop.
Save anonymous/2931188 to your computer and use it in GitHub Desktop.
testing activegist
# Your Assignment:
# (easy) First, print the numbers 1 to 10 in the console
puts "1. ---------------"
(1..10).each do |i|
puts i
end
# (medium) Second, Write a method that takes an array [-4,-76, 64, 200, -2, 644] and only prints positive integers
puts "2. ---------------"
def pos(arr)
arr.each do |i|
if (i > 0 && (i.kind_of? Integer))
puts i
end
end
end
pos([-2,-1,0,1,2,3,4.0])
# You write a question showing off a piece of ruby YOU love.
# How do you print the time right now?
puts "3. ---------------"
Time.now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment