Skip to content

Commit 4af2bc5

Browse files
committed
Add val.between?(start, end) to range comparisons
add value.between?(start, end) to range compares. It tested fastest against others on MRI 2.2.3, and tied for best on JRuby 9.0.4.0
1 parent 21540c1 commit 4af2bc5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

code/range/cover-vs-include.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
x.report('range#include?') { (BEGIN_OF_JULY..END_OF_JULY).include? DAY_IN_JULY }
1111
x.report('range#member?') { (BEGIN_OF_JULY..END_OF_JULY).member? DAY_IN_JULY }
1212
x.report('plain compare') { BEGIN_OF_JULY < DAY_IN_JULY && DAY_IN_JULY < END_OF_JULY }
13-
13+
x.report('value.between?') { DAY_IN_JULY.between?(BEGIN_OF_JULY, END_OF_JULY) }
14+
1415
x.compare!
1516
end

0 commit comments

Comments
 (0)