Sha256: 6c1bee504dd8584c4fad9bc4b73878252f43f2db6db48bf2e88a59fc7ef432fc

Contents?: true

Size: 539 Bytes

Versions: 2

Compression:

Stored size: 539 Bytes

Contents

= Cloneable

Require the library.

  require 'mixers/cloneable'

We'll use this dummy class.

  class Foo
    include Cloneable
    def initialize
      @bar=[]
    end
    def bar_id
      @bar.object_id
    end
  end

Try #dup.

  a = Foo.new
  b = a.dup
  b.bar_id.refute == a.bar_id

  a.taint
  b = a.dup
  b.assert.tainted?

  a.freeze
  b = a.dup
  b.refute.frozen?

Note try #clone.

  a = Foo.new
  b = a.clone
  b.bar_id.refute == a.bar_id

  a.taint
  b = a.dup
  b.assert.tainted?

  a.freeze
  b = a.clone
  b.assert.frozen?

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mixers-1.2.0 qed/02_cloneable.rdoc
mixers-1.1.0 qed/02_cloneable.rdoc