Chained expressions
Have you ever wanted to do a thing like the following in ruby?
a < b < c < d
Contrary to languages as python and perl6, ruby hasn't a native support to chained expressions, but you can implement them through a gem.
Install
$ gem install chainedexpressions
Example
require 'chainedexpressions'
using ChainedExpressions
20 < 25
20 < 25 < 30
20 <= 25 <= 30 <= 30 <= 35
35 > 30 > 25 > 20
20 > 3 > 2.2 > -2
35 >= 30 >= 30 >= 25 >= 20
Written by Giovanni Capuano
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#