提交 e522112d 编写于 作者: R Ryuta Kamizono

Remove caveat for older Ruby's `dup` behavior [ci skip]

In older Ruby, nil, Symbol, Fixnum, Rational, and Complex were not
duplicable. In Ruby 2.5, all of them are duplicable.
上级 f74098bf
...@@ -155,15 +155,6 @@ Complex(1).duplicable? # => true ...@@ -155,15 +155,6 @@ Complex(1).duplicable? # => true
1.method(:+).duplicable? # => false 1.method(:+).duplicable? # => false
``` ```
`duplicable?` matches the current Ruby version's `dup` behavior,
so results will vary according the version of Ruby you're using.
In Ruby 2.4, for example, Complex and Rational are not duplicable:
```ruby
Rational(1).duplicable? # => false
Complex(1).duplicable? # => false
```
WARNING: Any class can disallow duplication by removing `dup` and `clone` or raising exceptions from them. Thus only `rescue` can tell whether a given arbitrary object is duplicable. `duplicable?` depends on the hard-coded list above, but it is much faster than `rescue`. Use it only if you know the hard-coded list is enough in your use case. WARNING: Any class can disallow duplication by removing `dup` and `clone` or raising exceptions from them. Thus only `rescue` can tell whether a given arbitrary object is duplicable. `duplicable?` depends on the hard-coded list above, but it is much faster than `rescue`. Use it only if you know the hard-coded list is enough in your use case.
NOTE: Defined in `active_support/core_ext/object/duplicable.rb`. NOTE: Defined in `active_support/core_ext/object/duplicable.rb`.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册