Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Search and Destroy in Ruby

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for wtnabe wtnabe
September 28, 2013

Search and Destroy in Ruby

大ヒット連ドラ、あまちゃんの「見つけてこわそう」をヒントにRubyでこれを表現してみました。

Kanazawa.rb meetup #13 用のスライドでしたが、出席できなかったので @Yukimitsu_Izawa さんに喋ってもらいました。なんと、出席した人が誰もネタ知らなかったw

Avatar for wtnabe

wtnabe

September 28, 2013
Tweet

More Decks by wtnabe

Other Decks in Programming

Transcript

  1. ⾒つけてこわそう Search and Destroy ( or Seek and Destroy )

    in Ruby @wtnabe Kanazawa.rb meetup #13 2013-09-28 (Sat) at ITプラザ武蔵
  2. こう Object.constants.sort.map {|e| Object.const_get(e.to_s) }.select {|e| e.class == Class }

    [ArgumentError, Array, BasicObject, Bignum, Binding, Class, Complex, ...
  3. 直せるようにしておく require 'date' d = Date Date = nil Date.today

    # => NoMethodError: undefined metho Date = d Date.today.to_s # => '2013-09-28'
  4. 壊す s = 'ABC' s.downcase # => 'abc' s.instance_eval {

    def downcase '' end } s.downcase # => ''
  5. 壊す s = 'ABC' s.downcase # => 'abc' s.instance_eval {

    class << self alias_method :downcase_org, :downcase undef_method :downcase end } s.downcase # => NoMethodError: undefined metho