Skip to content

Instantly share code, notes, and snippets.

@ddollar
Created July 22, 2009 19:09
Show Gist options
  • Select an option

  • Save ddollar/152196 to your computer and use it in GitHub Desktop.

Select an option

Save ddollar/152196 to your computer and use it in GitHub Desktop.
class Symbol
def to_proc
Proc.new { |*args| args.shift.send(self, *args) }
end
end
class Fixnum
def is_a_multiple_of?(multiples)
multiples.detect { |multiple| (self % multiple).zero? }
end
end
class Array
def sum
self.inject(&:+)
end
end
module Enumerable
def multiples_of(*multiples)
self.select { |i| i.is_a_multiple_of?(multiples) }
end
end
puts (1..999).multiples_of(3,5).sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment