One minute
Use ‘range’ or ‘between’ for numerical comparison 🧮
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