Check if an integer is within a range [duplicate]

There are many ways of doing the same things in Ruby. You can check if value is in the range by use of following methods,

14.between?(10,20) # true

(10..20).member?(14) # true

(10..20).include?(14) # true

But, I would suggest using between? rather than member? or include?

All number literals denote inclusive ranges.
You can find more about it on Ruby in Rails.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)