Sha256: f54de27f6c37aab7355b0b7a6169e1a10f56b944f8959b44099fe44a1bac21ba

Contents?: true

Size: 520 Bytes

Versions: 6

Compression:

Stored size: 520 Bytes

Contents

# $Id: style.rb 38 2007-08-27 13:03:39Z 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(:+) { 1 }
musha.swap {
  p one_plus_one #=> 1
}

p one_plus_one #=> 2

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

p one_plus_one #=> 2

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

p one_plus_one #=> 2

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kagemusha-0.0.4 examples/style.rb
kagemusha-0.0.2 examples/style.rb
kagemusha-0.0.3 examples/style.rb
kagemusha-0.0.5 examples/style.rb
kagemusha-0.0.6 examples/style.rb
kagemusha-0.0.7 examples/style.rb