# Division hangs irb

**URL:** <https://www.ruby-forum.com/t/division-hangs-irb/79953>\
**Category:** Ruby\
**Created:** [December 20, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/division-hangs-irb/79953 "2006-12-20T19:12:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [December 20, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/division-hangs-irb/79953/1 "2006-12-20T19:12:19Z")

</div>

Anyone know why the first three of these calculations works on my irb  
(on intel OS X 10.4.8), but the last one silently hangs?

> > (DateTime.now - Date.new(2006,9,15)).to\_f / 30  
> > =\> 3.18572031018981
> 
> > (DateTime.now - Date.new(2006,9,15)).to\_f/ 30  
> > =\> 3.18572102628549
> 
> > (DateTime.now - Date.new(2006,9,15)).to\_f/30  
> > =\> 3.18572174544174
> 
> > (DateTime.now - Date.new(2006,9,15)).to\_f /30  
> >   
> > ^C

Ashley

---

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [December 20, 2006, 7:16pm UTC](https://www.ruby-forum.com/t/division-hangs-irb/79953/2 "2006-12-20T19:16:35Z")

</div>

Ashley M. wrote:

> Anyone know why the first three of these calculations works on my irb  
> (on intel OS X 10.4.8), but the last one silently hangs?
> 
> > > (DateTime.now - Date.new(2006,9,15)).to\_f / 30  
> > > =\> 3.18572031018981
> > 
> > > (DateTime.now - Date.new(2006,9,15)).to\_f/ 30  
> > > =\> 3.18572102628549
> > 
> > > (DateTime.now - Date.new(2006,9,15)).to\_f/30  
> > > =\> 3.18572174544174
> > 
> > > (DateTime.now - Date.new(2006,9,15)).to\_f /30

Irb takes the latter as the beginning of a regular expression for the  
first argument of to\_f:

> > (DateTime.now - Date.new(2006,9,15)).to\_f /30  
> > /  
> > ArgumentError: wrong number of arguments (1 for 0)  
> > from (irb):10:in `to\_f’  
> > from (irb):10  
> > from /usr/lib/ruby/1.8/rational.rb:520

Cheers,

```
Vince
```

---

<div class="post-metadata">

**Author:** ![Ashley\_M](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@Ashley\_M](https://www.ruby-forum.com/u/Ashley_M)\
**Post date:** [December 20, 2006, 7:18pm UTC](https://www.ruby-forum.com/t/division-hangs-irb/79953/3 "2006-12-20T19:18:37Z")

</div>

On Tue, 19 Dec 2006 23:06:05 +0900, Vincent F. wrote:

> > > > (DateTime.now - Date.new(2006,9,15)).to\_f /30
> 
> Irb takes the latter as the beginning of a regular expression for the  
> first argument of to\_f:

…therefore IRB is still waiting for input. But you should see the a  
prompt when you hit enter, with a different ending character (/ instead  
of

> ) to indicate that IRB is still waiting for input.
