instance method ObjectRange#include

View source on GitHub →

ObjectRange#include(value) → Boolean

Determines whether the value is included in the range.

This assumes the values in the range have a valid strict weak ordering (have valid semantics for the < operator). While ObjectRange mixes in Enumerable, this method overrides the default version of Enumerable#include, and is much more efficient (it uses a maximum of two comparisons).

$R(1, 10).include(5);
// -> true
 $R('a', 'h').include('x');
// -> false
 $R(1, 10).include(10);
// -> true
 $R(1, 10, true).include(10);
// -> false