Skip to content

Instantly share code, notes, and snippets.

@cyx
Created April 6, 2010 10:34
Show Gist options
  • Save cyx/357449 to your computer and use it in GitHub Desktop.
Save cyx/357449 to your computer and use it in GitHub Desktop.
# use e for elements of an Enumerable
Item.all.each { |e| puts e.name }
# use f for files
Dir["app/**/*.rb"].each { |f| require f }
# use ex for rescued Exceptions
begin
open(uri)
rescue OpenURI::HttpError => ex
puts "Unable to retrieve #{uri}"
end
# i, j for indices. this actually dates back to C/C++ days in college
for i in 1..10
for j in i..10
puts "#{i}, #{j}"
end
end
# x, y, z numbers, definitely reminiscent of math
x, y = 5, 10
z = x * y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment