What does IRB's "=>" show?

I don’t quite understand what irb’s “=>” is showing. In particular, I’d like to
know how to change it.

Currently I get:

p = X**2 - 1
=> #<Math::Polynomial::Poly:0x1a4c48 @coeffs=[-1, 0, 1]>

And I’d rather it produce something like:

p = X2 - 1
=> X
2 - 1

Or better yet:

p = X**2 - 1
=>
2
X - 1

Is this possible?

···


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

It uses #inspect, so just define a #inspect method for Poly, and You’ll
be set!

···

Daniel Carrera (dcarrera@math.umd.edu) wrote:

I don’t quite understand what irb’s “=>” is showing. In particular, I’d like to
know how to change it.

Currently I get:

p = X**2 - 1
=> #<Math::Polynomial::Poly:0x1a4c48 @coeffs=[-1, 0, 1]>

And I’d rather it produce something like:

p = X2 - 1
=> X
2 - 1

Or better yet:

p = X**2 - 1
=>
2
X - 1

Is this possible?


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

It calls ‘inspect’ on the result of an expression and displays it. You can
instruct irb to use to_s instead, for instance with command line
option --noinspect.

Gennady.

···

----- Original Message -----
From: “Daniel Carrera” dcarrera@math.umd.edu
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, February 06, 2003 2:07 PM
Subject: What does IRB’s “=>” show?

I don’t quite understand what irb’s “=>” is showing. In particular, I’d
like to
know how to change it.

Currently I get:

p = X**2 - 1
=> #<Math::Polynomial::Poly:0x1a4c48 @coeffs=[-1, 0, 1]>

And I’d rather it produce something like:

p = X2 - 1
=> X
2 - 1

Or better yet:

p = X**2 - 1
=>
2
X - 1

Is this possible?


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

Thanks. That was easy enough.
Not it looks great:

(X-1)*(X+1)
=>
2
X - 1

···


Daniel Carrera
Graduate Teaching Assistant. Math Dept.
University of Maryland. (301) 405-5137

Thanks. That was easy enough.
Not it looks great:

(X-1)*(X+1)
=>>
2
X - 1

I’m looking forward to seeing this class!

Gavin

···

On Friday, February 7, 2003, 9:22:41 AM, Daniel wrote: