(0..4).step(obj with to_int)

e$B0J2<$N$h$&$K!"e(Bstep e$B$N0z?t$Ke(B to_int
[email protected]?t$b$I$-$rM?$($ke(B
e$B$HNc30$K$J$j$^$9!#e(B

% ./ruby -ve ‘o=Object.new; def o.to_int() 1 end; (0…4).step(o) {|v| p
v }’
ruby 1.9.0 (2008-05-01 revision 16250) [i686-linux]
0
-e:1:in +': Object can't be coerced into Fixnum (TypeError) from -e:1:instep’
from -e:1:in `’

1.8.6p111 e$B$G$O$J$j$^$;$s$G$7$?!#e(B

% ruby-1.8.6p111 -ve ‘o=Object.new; def o.to_int() 1 end;
(0…4).step(o) {|v| p v }’
ruby 1.8.6 (2007-09-24 patchlevel 111) [i686-linux]
0
1
2
3
4

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs