Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Improve documentation of Range#size #501

Closed
wants to merge 1 commit into from

2 participants

@skade

Documents the case where the range is not Numeric.
Adds an example for the case where the range is not Numeric.
Adds an example for the case where the method returns Infinity.

range.c
((7 lines not shown))
*
* (10..20).size #=> 11
+ * ('a'..'z'.size) #=> nil
@eregon Collaborator
eregon added a note

the ) should be before the .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
range.c
((7 lines not shown))
*
* (10..20).size #=> 11
+ * ('a'..'z'.size) #=> nil
+ * (-Float::INFINITY..Float::INFINITY) #=> Infinity
@eregon Collaborator
eregon added a note

missing .size at the end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@skade skade Improve documentation of Range#size
Documents the case where the range is not Numeric.
Adds an example for the case where the range is not Numeric.
Adds an example for the case where the method returns Infinity.
7402377
@skade

@eregon Eh. Yes. Always double-check your commits after lunch.

I amended the patch.

Thanks for noticing.

@eregon eregon closed this pull request from a commit
@eregon eregon * range.c (Range#size): [DOC] improve description and add examples.
  Patch by @skade. [Fixes GH-501]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
d31cd06
@eregon eregon closed this in d31cd06
@eregon
Collaborator

Merged, thanks!

@mmasaki mmasaki referenced this pull request from a commit in mmasaki/ruby
@eregon eregon * range.c (Range#size): [DOC] improve description and add examples.
  Patch by @skade. [Fixes GH-501]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
001eb39
@tenderlove tenderlove referenced this pull request from a commit in tenderlove/ruby
@eregon eregon * range.c (Range#size): [DOC] improve description and add examples.
  Patch by @skade. [Fixes GH-501]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
aa57b67
@evanphx evanphx referenced this pull request from a commit
@nagachika nagachika merge revision(s) r44549: [Backport #9387]
	* range.c (Range#size): [DOC] improve description and add examples.
	  Patch by @skade. [Fixes GH-501]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
0e35061
@nurse nurse referenced this pull request from a commit
@nurse nurse merge revision(s) 44549: [Backport #9387]
	* range.c (Range#size): [DOC] improve description and add examples.
	  Patch by @skade. [Fixes GH-501]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
b3445c0
@funky-bibimbap funky-bibimbap referenced this pull request from a commit in funky-bibimbap/ruby
@eregon eregon * range.c (Range#size): [DOC] improve description and add examples.
  Patch by @skade. [Fixes GH-501]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
64559e6
@mrkn mrkn referenced this pull request from a commit in mrkn/ruby
@nurse nurse merge revision(s) 44549: [Backport #9387]
	* range.c (Range#size): [DOC] improve description and add examples.
	  Patch by @skade. [Fixes GH-501]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@45118 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
f1161c9
@hsbt hsbt referenced this pull request from a commit
@nagachika nagachika merge revision(s) r44549: [Backport #9387]
	* range.c (Range#size): [DOC] improve description and add examples.
	  Patch by @skade. [Fixes GH-501]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@45013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
9d6dd89
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 9, 2014
  1. @skade

    Improve documentation of Range#size

    skade authored
    Documents the case where the range is not Numeric.
    Adds an example for the case where the range is not Numeric.
    Adds an example for the case where the method returns Infinity.
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 1 deletion.
  1. +4 −1 range.c
View
5 range.c
@@ -711,9 +711,12 @@ sym_each_i(RB_BLOCK_CALL_FUNC_ARGLIST(v, arg))
* call-seq:
* rng.size -> num
*
- * Returns the number of elements in the range.
+ * Returns the number of elements in the range. Both the begin and the end of
+ * the Range must be Numeric, otherwise nil is returned.
*
* (10..20).size #=> 11
+ * ('a'..'z').size #=> nil
+ * (-Float::INFINITY..Float::INFINITY).size #=> Infinity
*/
static VALUE
Something went wrong with that request. Please try again.