ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: naruse@airemix.jp
To: ruby-core@ruby-lang.org
Subject: [ruby-core:91331] [Ruby trunk Bug#15518] good old Infinite range notation behavior
Date: Wed, 30 Jan 2019 06:20:14 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-76582.20190130062013.456ec213a2d20549@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15518.20190109054414@ruby-lang.org

Issue #15518 has been updated by naruse (Yui NARUSE).

Backport changed from 2.4: DONTNEED, 2.5: DONTNEED, 2.6: REQUIRED to 2.4: DONTNEED, 2.5: DONTNEED, 2.6: DONE

ruby_2_6 r66949 merged revision(s) 66947.

----------------------------------------
Bug #15518: good old Infinite range notation behavior
https://bugs.ruby-lang.org/issues/15518#change-76582

* Author: sakuro (Sakuro OZAWA)
* Status: Closed
* Priority: Normal
* Assignee: mrkn (Kenta Murata)
* Target version: 
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin18]
* Backport: 2.4: DONTNEED, 2.5: DONTNEED, 2.6: DONE
----------------------------------------
Ruby 2.5.3's behavior

~~~
# without step, it produces integer sequence
(1..Float::INFINITY).first(10) #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# with step, it produces floats instead of integers
(1..Float::INFINITY).step(1).first(10) #=> [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]
~~~

Ruby 2.6.0's behavior

~~~
# endless range
(1..).first(10) #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
# with step, all numbers are integer now
(1..).step(1).first(10) #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

# old idiom with Float::INFINITY
(1..Float::INFINITY).first(10) #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
(1..Float::INFINITY).step(1).first(10) #=> FloatDomainError (Infinity)
~~~

Which are intended change and which are not?




-- 
https://bugs.ruby-lang.org/

      parent reply	other threads:[~2019-01-30  6:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15518.20190109054414@ruby-lang.org>
2019-01-09  5:44 ` [ruby-core:90937] [Ruby trunk Bug#15518] good old Infinite range notation behavior sakuro+ruby-lang.org
2019-01-09  7:19 ` [ruby-core:90940] " sawadatsuyoshi
2019-01-09  8:34 ` [ruby-core:90941] [Ruby trunk Bug#15518][Assigned] " muraken
2019-01-09  9:35 ` [ruby-core:90942] [Ruby trunk Bug#15518] " muraken
2019-01-30  6:16 ` [ruby-core:91330] " muraken
2019-01-30  6:20 ` naruse [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-76582.20190130062013.456ec213a2d20549@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).