Sha256: 4fc5d578ac38c15e1b445307dba09c1b2f62670e4f50f274af66ea4af90eecbf

Contents?: true

Size: 548 Bytes

Versions: 1

Compression:

Stored size: 548 Bytes

Contents

# coding: utf-8
# $Id: style.rb 120 2009-02-09 08:22:25Z yuyakato $

require "rubygems"
require "kagemusha"

def one_plus_one
  return 1 + 1
end

p one_plus_one #=> 2

# Normal Style.
musha = Kagemusha.new(Fixnum)
musha.def(:+) { |x| 1 }
musha.swap {
  p one_plus_one #=> 1
}

p one_plus_one #=> 2

# Block Style.
Kagemusha.new(Fixnum) { |m|
  m.def(:+) { |x| 1 }
  m.swap {
    p one_plus_one #=> 1
  }
}

p one_plus_one #=> 2

# Chain Style.
Kagemusha.new(Fixnum).
  def(:+) { |x| 1 }.
  swap {
    p one_plus_one #=> 1
  }

p one_plus_one #=> 2

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kagemusha-0.0.8 examples/style.rb