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!

Ruby’s case statement – advanced techniques

Nothing could be simpler and more boring than the case statement. It’s a holdover from C. You use it to replace a bunch of ifs. Case closed. Or is it? Actually, case statements in Ruby are a lot richer and more complex than you might imagine. Let’s take a look. http://blog.honeybadger.io/rubys-case-statement-advanced-techniques/

Comments

` class Success def self.===(item) item.status >= 200 && item.status < 300 end end

class Empty def self.===(item) item.response_size == 0 end end `

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