More Inspections

Some of IRB's command-line options can be called idiosyncratic as well. Take math mode¹ as an example: It will require the infamous mathn library on start up:

$ irb -m
>> Math #=> CMath
>> 3/2 #=> (3/2)
>> !!defined?(Vector) #=> true

¹ Math mode actually has been removed in Ruby version 2.5

And another one surprised me: You can pass custom inspectors to IRB, for example, yaml:

$ irb -f --inspect yaml
>> [1,2,3]
=> ---
- 1
- 2
- 3

Or marshal:

$ irb -f --inspect marshal
>> 42
=> i/

But you can also define your own inspectors on the fly:

$ irb -f --inspect "{ |r| r.to_s.reverse }"
>> [1,2,3]
=> ]3 ,2 ,1[

It will be eval'd (!) as the block part of a new proc.

Resources

More Idiosyncratic Ruby