Project

General

Profile

Actions

Bug #2951

closed

range stop em method include? out of range

Added by ariveira (Alexandre Riveira) about 14 years ago. Updated almost 13 years ago.

Status:
Rejected
Assignee:
-
ruby -v:
1.9.1-p378
[ruby-core:28599]

Description

=begin
This example stop ruby 1.9.1-p378

("01001-000".."99990-000").include? ""
=end

Actions #1

Updated by naruse (Yui NARUSE) about 14 years ago

  • Status changed from Open to Rejected

=begin
It iterates (99990-1001) * 1000 + 1 = 98989001 times.
So it will nearly stopped.
=end

Actions #2

Updated by ariveira (Alexandre Riveira) about 14 years ago

=begin
ruby 1.8.7-p249 is minor of 0 seconds example
start_time = Time.now; ("01001-000".."99990-000").include? ""; puts Time.now - start_time
1.4e-05
=> nil

ruby 1.9.1
/usr/local/ruby-1.9.1-p378/bin/irb
irb(main):001:0> start_time = Time.now; ("01001-000".."99990-000").include? ""; puts Time.now - start_time
80.55897691
=> nil
Because ruby 1.8.7's extremely fast and ruby 1.9.1 is so slow?
This is a bug !

=end

Actions #3

Updated by marcandre (Marc-Andre Lafortune) about 14 years ago

=begin
Behavior has changed in 1.9. Please read the NEWS file:
http://github.com/ruby/ruby/blob/ruby_1_9_1/NEWS#L288
=end

Actions #4

Updated by ariveira (Alexandre Riveira) about 14 years ago

=begin
I used the method Range#cover? and now had the behavior I expected !

start_time = Time.now; ("01001-000".."99990-000").cover? ""; puts Time.now - start_time
2.1022e-05
=> nil

Tank's

Alexandre Riveira
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0