Files
news.gitea.happylizard.me/bin/gems/facets-3.1.0/demo/standard/02_cloneable.rdoc
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

47 lines
539 B
Plaintext

= Cloneable
Require the library.
require 'facets/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?