Skip to content

Instantly share code, notes, and snippets.

@ascendbruce
Created October 20, 2013 15:28
Show Gist options
  • Select an option

  • Save ascendbruce/7071080 to your computer and use it in GitHub Desktop.

Select an option

Save ascendbruce/7071080 to your computer and use it in GitHub Desktop.
ruby 陽春模仿 1.year/month/day, Array#sum
# ruby Fixnum# year/month/day
class Fixnum
def minutes
self*60
end
def hours
self*60*60
end
def days
self*24*60*60
end
end
# Array#sum
# ruby 1.9 above:
array.inject(:+)
# ruby 1.8:
array.inject{|sum,x| sum + x }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment