Last active
September 5, 2018 22:00
-
-
Save packrat386/18ffc5f91fd42cb04c15397c23ec7469 to your computer and use it in GitHub Desktop.
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
def myfunc(prog = "") | |
mystr = "hi there" | |
eval(prog) | |
mystr.scream | |
end | |
puts 'first' | |
begin | |
myfunc | |
rescue => e | |
puts "got error #{e}" | |
end | |
puts '================' | |
puts 'second' | |
begin | |
myfunc('class String; def scream; $stdout.puts self.upcase; end; end;') | |
rescue => e | |
puts "got error #{e}" | |
end | |
class Screamer | |
def scream | |
puts 'AAAAAAH' | |
end | |
end | |
puts '================' | |
puts 'third' | |
begin | |
myfunc('mystr = Screamer.new') | |
rescue => e | |
puts "got error #{e}" | |
end | |
=begin | |
first | |
got error undefined method `scream' for "hi there":String | |
================ | |
second | |
HI THERE | |
================ | |
third | |
AAAAAAH | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment