Project

General

Profile

Actions

Bug #574

closed

Proc.new{}.arity is equal to -1 instead of 0

Added by gendag (Andrea Forni) over 15 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
[ruby-core:18708]

Description

=begin
In the ruby documentation for the versions 1.8.6, 1.8.7 and 1.9 is written about the method Proc#arity:
Proc.new {}.arity #=> 0
Proc.new {||}.arity #=> 0
Proc.new {|a|}.arity #=> 1
...
But in my scripts Proc.new{}.arity is equal to -1 and Proc.new{||}.arity is equal to zero.

The script attached to this issue shows the problem. I have tested it in my Linux box (Ubuntu hardy 8.04LTS architecture: i686 ) using both:

  1. ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
  2. ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]

Here the output:
$ ruby --version
ruby 1.8.6 (2007-09-24 patchlevel 111) [i486-linux]
$ ruby proc_arity.rb
-1
0
1
2
3
$ ruby --version
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]
$ ruby proc_arity.rb
-1
0
1
2
3

Where is the problem? It's a ruby's bug or a documentation one?
=end


Files

proc_arity.rb (127 Bytes) proc_arity.rb gendag (Andrea Forni), 09/19/2008 04:18 AM
Actions #1

Updated by shyouhei (Shyouhei Urabe) about 15 years ago

  • Assignee set to knu (Akinori MUSHA)

=begin

=end

Actions #2

Updated by nobu (Nobuyoshi Nakada) about 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r22979.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0