Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- class String ### Open standard class String
- def puts_uppercase ## Add a method
- puts upcase
- end
- end
- "asdasd".puts_uppercase
- class String
- alias :old_puts_uppercase :puts_uppercase # save original puts_uppercase method
- def puts_uppercase # and override it
- "HELLO #{self}".old_puts_uppercase
- end
- end
- "asdasdas".puts_uppercase
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement