This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'fiddle' | |
A = Class.new | |
B = Class.new | |
C = Class.new A | |
p C.superclass # => A | |
(Fiddle::Pointer[Fiddle.dlwrap C] + 16)[0, 8] = Fiddle::Pointer[Fiddle.dlwrap B].ref | |
p C.superclass # => B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'equalizer' | |
module Checkproc | |
InvalidValueError = Class.new(StandardError) { include Equalizer.new(:message) } | |
class Composite | |
attr_reader :left | |
attr_reader :right | |
def initialize(left, right) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calculating ------------------------------------- | |
method 56.995k i/100ms | |
proc 49.213k i/100ms | |
proc new 57.562k i/100ms | |
------------------------------------------------- | |
method 1.797M (±10.7%) i/s - 8.891M | |
proc 1.522M (± 8.3%) i/s - 7.579M | |
proc new 1.867M (± 7.9%) i/s - 9.267M | |
Comparison: |