Division hangs irb

A

Ashley Moran

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?
<not a lot happening>
^C

Ashley
 
V

Vincent Fourmond

Ashley said:
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?

Irb takes the latter as the beginning of a regular expression for the
first argument of to_f:
/
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
 
A

Ashley Moran

Irb takes the latter as the beginning of a regular expression for
the
first argument of to_f:

/
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


Thanks Vince, cleared that up

I wondered why that didn't work but "10 /5" did

Ashley
 
K

Ken Bloom

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
 
V

Vincent Fourmond

Ken said:
...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

Actually, no: I did type the /. This way, I finish the regexp started
on the previous line, and the expression is parsed and causes an error.
By the way, is there a way to define a secondary prompt in IRB ?

Vince
 
K

Kalman Noel

Vincent Fourmond:
By the way, is there a way to define a secondary prompt in IRB ?

Maybe that is :pROMPT_S.

IRB.conf[:pROMPT][:CUSTOM] = {
:pROMPT_I => # Insert
:pROMPT_C => # your
:pROMPT_N => # favorite
:pROMPT_S => # strings
:RETURN => # here
}
IRB.conf[:pROMPT_MODE] = :CUSTOM

Kalman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,221
Messages
2,571,133
Members
47,747
Latest member
swapote

Latest Threads

Top