# (1..5).step(SimpleDelegator.new(1.5)) {|x| p x} differ from (1..5).step(1.5) {|x| p x}

**URL:** <https://www.ruby-forum.com/t/1-5-step-simpledelegator-new-1-5-x-p-x-differ-from-1-5-step-1-5-x-p-x/138157>\
**Category:** Development\
**Created:** [May 20, 2008, 5:38pm UTC](https://www.ruby-forum.com/t/1-5-step-simpledelegator-new-1-5-x-p-x-differ-from-1-5-step-1-5-x-p-x/138157 "2008-05-20T17:38:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [May 20, 2008, 5:38pm UTC](https://www.ruby-forum.com/t/1-5-step-simpledelegator-new-1-5-x-p-x-differ-from-1-5-step-1-5-x-p-x/138157/1 "2008-05-20T17:38:23Z")

</div>

e$B0J2\<$N$h$&$Ke(B (1…5).step(1.5) {|x| p x} e$B$He(B  
(1…5).step(SimpleDelegator.new(1.5)) {|x| p x} e$B$N7k2L$,0[$Je(B  
e$B$k$N$OJQ$G$O$J$$$G$7$g$&$+!#e(B

% ./ruby -ve ‘(1…5).step(1.5) {|x| p x}’  
ruby 1.9.0 (2008-05-20 revision 16494) [i686-linux]  
1  
2.5  
4.0  
% ./ruby -rdelegate -e ‘(1…5).step(SimpleDelegator.new(1.5)) {|x| p x}’  
1  
2  
3  
4  
5

---

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [May 21, 2008, 3:16am UTC](https://www.ruby-forum.com/t/1-5-step-simpledelegator-new-1-5-x-p-x-differ-from-1-5-step-1-5-x-p-x/138157/2 "2008-05-21T03:16:49Z")

</div>

e$B$J$+$@$G$9!#e(B

At Wed, 21 May 2008 00:37:24 +0900,  
Tanaka A. wrote in [ruby-dev:34775]:

> e$B0J2\<$N$h$&$Ke(B (1…5).step(1.5) {|x| p x} e$B$He(B  
> (1…5).step(SimpleDelegator.new(1.5)) {|x| p x} e$B$N7k2L$,0[$Je(B  
> e$B$k$N$OJQ$G$O$J$$$G$7$g$&$+!#e(B

e$B$d$O$j!"e(BFloat#to\_inte$B$OGQ;\_$9$k$3$H$r\<gD%$7$^$9!#e(B

# Index: numeric.c

— numeric.c (revision 16501)  
+++ numeric.c (working copy)  
@@ -454,18 +454,4 @@ num\_nonzero\_p(VALUE num)  
}

-/\*

- 
  - call-seq:

- 
  - 

```
num.to_int => integer

```

- 
  - 

- 
  - Invokes the child class’s `to_i` method to convert

- 
  - _num_ to an integer.

- \*/
- 

-static VALUE  
-num\_to\_int(VALUE num)  
-{

- return rb\_funcall(num, id\_to\_i, 0, 0);  
-}
- 

/\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
@@ -3116,5 +3102,4 @@ Init\_Numeric(void)  
rb\_define\_method(rb\_cNumeric, “remainder”, num\_remainder, 1);  
rb\_define\_method(rb\_cNumeric, “abs”, num\_abs, 0);

- rb\_define\_method(rb\_cNumeric, “to\_int”, num\_to\_int, 0);

- rb\_define\_method(rb\_cFloat, “to\_int”, flo\_truncate, 0);  
rb\_define\_method(rb\_cFloat, “floor”, flo\_floor, 0);  
rb\_define\_method(rb\_cFloat, “ceil”, flo\_ceil, 0);  
Index: range.c  
===================================================================  
— range.c (revision 16501)  
+++ range.c (working copy)  
@@ -307,6 +307,7 @@ range\_step(int argc, VALUE \*argv, VALUE  
else {  
rb\_scan\_args(argc, argv, “01”, &step);

- if (!rb\_obj\_is\_kind\_of(step, rb\_cNumeric)) {

- 

```
 step = rb_to_int(step);

```

- tmp = rb\_check\_to\_integer(step, “to\_int”);
- if (!NIL\_P(tmp)) {
- 

```
 step = tmp;

```

}  
if (rb\_funcall(step, ‘\<’, 1, INT2FIX(0))) {  
Index: lib/delegate.rb  
===================================================================  
— lib/delegate.rb (revision 16501)  
+++ lib/delegate.rb (working copy)  
@@ -153,7 +153,7 @@ class Delegator
# call through \_\_getobj\_\_.

# 

- def respond\_to?(m)

- def respond\_to?(m, \*priv)  
return true if super

- 

```
 return self. __getobj__.respond_to?(m)

```

- 

```
 return self. __getobj__.respond_to?(m, *priv)

```

end

---

<div class="post-metadata">

**Author:** ![Tanaka\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@Tanaka\_A](https://www.ruby-forum.com/u/Tanaka_A)\
**Post date:** [May 21, 2008, 10:09am UTC](https://www.ruby-forum.com/t/1-5-step-simpledelegator-new-1-5-x-p-x-differ-from-1-5-step-1-5-x-p-x/138157/3 "2008-05-21T10:09:26Z")

</div>

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:34780] Re:  
(1…5).step(SimpleDelegator.new(1.5)) {|x| p x} differ from  
(1…5).step(1.5) {|x| p x}”  
on Wed, 21 May 2008 10:16:16 +0900, Nobuyoshi N.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) writes:

|At Wed, 21 May 2008 00:37:24 +0900,  
|Tanaka A. wrote in [ruby-dev:34775]:  
|\> e$B0J2\<$N$h$&$Ke(B (1…5).step(1.5) {|x| p x} e$B$He(B  
|\> (1…5).step(SimpleDelegator.new(1.5)) {|x| p x} e$B$N7k2L$,0[$Je(B  
|\> e$B$k$N$OJQ$G$O$J$$$G$7$g$&$+!#e(B  
|  
|e$B$d$O$j!"e(BFloat#to\_inte$B$OGQ;\_$9$k$3$H$r\<gD%$7$^$9!#e(B

to\_floate$B$rMQ0U$7$F$=$C$A$r@h$K8+$k!"$H$+!#e(B  
1.9e$B$@$7!"GQ;\_$7$F$O$$$1$J$$$H$O8@$o$J$$$1$I!"1F6AHO0O$r8+@Qe(B  
e$B$b$j$?$$5$$b$7$^$9!#e(B
