One minute
Use ‘range’ or ‘between’ for numerical comparison 🧮
![Numerical comparison using `range` and `between` 😊](https://dl.dropbox.com/s/ejnnfnh0mqbe7z5/range-between.png)
Do you know we can use range or between to do numerical comparison in ruby? 🤔
Code Snippet -
do_something if x >= 100 && x <= 200
# Use Range
do_something if (100..200).include?(x)
# Use between
do_something if x.between?(100, 200)
Read other posts
comments powered by Disqus