Messing With Ruby

I’m overriding concatenation here, which completely messes up Ruby’s interactive console:

tsadok$ irb
irb(main):001:0> class String; def +(s); "no"; end; end
=> nil
irb(main):no:0> yes
irb(main):no:0> 1 + 1
irb(main):no:0> puts "hi"
irb(main):no:0> ^D
NameError: undefined local variable or method `nononono' for main:Object
no
irb(main):no:0> ^D
tsadok$
Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s