Last active
August 29, 2015 14:02
-
-
Save nedzadarek/8e80077e9e0c61052e15 to your computer and use it in GitHub Desktop.
Monkey patching `to_s` of Fixnum's class. Running it from the pry session as commands.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts `ruby -e 'class Fixnum; def to_s; "WHAT"; end; end; puts 42.to_s; puts "#{3 * 4}";'` | |
# WHAT | |
# 12 | |
# this one works only in the pry | |
# .ruby -e 'class Fixnum; def to_s; "WHAT"; end; end; puts 42.to_s; puts "#{3 * 4}";' | |
# WHAT | |
# 12 | |
system(%q{ruby -e 'class Fixnum; def to_s; "WHAT"; end; end; puts 42.to_s; puts "#{3 * 4}";'}) | |
# WHAT | |
# WHAT | |
exec(%q{ruby -e 'class Fixnum; def to_s; "WHAT"; end; end; puts 42.to_s; puts "#{3 * 4}";'}) | |
# WHAT | |
# WHAT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment