RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Unlocking The Power Of Case Equality: Proc#===

Range, Class and Regexp all implement their own version of ===, so why not Proc?

Comments

You can shortcut multiples_of_5 = Proc.new{|*parameters| parameters.map{|i| i.modulo(5).zero?}.all?} to multiples_of_5 = Proc.new{|*parameters| parameters.all? { |i| i.modulo(5).zero?}}

Better and IMO nicer. regards

Thanks for the shortcut. We’ve changed that line to your version.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in