Skip to content

Instantly share code, notes, and snippets.

@ivanacostarubio
Created May 7, 2012 20:15
Show Gist options
  • Select an option

  • Save ivanacostarubio/2630117 to your computer and use it in GitHub Desktop.

Select an option

Save ivanacostarubio/2630117 to your computer and use it in GitHub Desktop.
Saving what super retuns !!! OMG :trollface:
b[scoping_books] ivan@~/ruby/e-read-report λ irb
ruby-1.9.3-p0 :001 > class SuperMan
ruby-1.9.3-p0 :002?> def vuela
ruby-1.9.3-p0 :003?> return "volando"
ruby-1.9.3-p0 :004?> end
ruby-1.9.3-p0 :005?> end
=> nil
ruby-1.9.3-p0 :022 > class Superr < SuperMan
ruby-1.9.3-p0 :023?> def vuela
ruby-1.9.3-p0 :024?> retorna = super
ruby-1.9.3-p0 :025?> puts retorna
ruby-1.9.3-p0 :026?> puts "super"
ruby-1.9.3-p0 :027?> end
ruby-1.9.3-p0 :028?> end
=> nil
ruby-1.9.3-p0 :029 > Superr.new.vuela
volando
super
=> nil
ruby-1.9.3-p0 :001 > module Cabron
ruby-1.9.3-p0 :002?> def chingon
ruby-1.9.3-p0 :003?> return "esta cabron"
ruby-1.9.3-p0 :004?> end
ruby-1.9.3-p0 :005?> end
=> nil
ruby-1.9.3-p0 :006 > class Ivan
ruby-1.9.3-p0 :007?> include Cabron
ruby-1.9.3-p0 :008?> def chingon
ruby-1.9.3-p0 :009?> r = super
ruby-1.9.3-p0 :010?> puts r
ruby-1.9.3-p0 :011?> puts "el super"
ruby-1.9.3-p0 :012?> end
ruby-1.9.3-p0 :013?> end
=> nil
ruby-1.9.3-p0 :014 > Ivan.new.chingon
esta cabron
el super
=> nil
ruby-1.9.3-p0 :015 >
ruby-1.9.3-p0 :040 > class Orlando
ruby-1.9.3-p0 :041?> def chingon
ruby-1.9.3-p0 :042?> puts "esta"
ruby-1.9.3-p0 :043?> r = super
ruby-1.9.3-p0 :044?> puts r
ruby-1.9.3-p0 :045?> puts "cabron"
ruby-1.9.3-p0 :046?> end
ruby-1.9.3-p0 :047?> include Cabron
ruby-1.9.3-p0 :048?> end
=> Orlando
ruby-1.9.3-p0 :049 > Orlando.new.chingon
esta
esta cabron
cabron
=> nil
ruby-1.9.3-p0 :104 > def er_block
ruby-1.9.3-p0 :105?> puts "A"
ruby-1.9.3-p0 :106?> yield
ruby-1.9.3-p0 :107?> puts "B"
ruby-1.9.3-p0 :108?> end
=> nil
ruby-1.9.3-p0 :109 > er_block {puts "this is to hot" }
A
this is to hot
B
=> nil
ruby-1.9.3-p0 :110 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment