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