Sha256: 90b6942ea1ab20c8cfc31162ecf6aabcab9d485fe16aee4f27ebf476b3bd1aca

Contents?: true

Size: 496 Bytes

Versions: 1

Compression:

Stored size: 496 Bytes

Contents

# coding: utf-8

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
nayutaya-kagemusha-0.1.0 examples/style.rb