|
Revision 7906, 472 bytes
(checked in by bitsweat, 11 months ago)
|
object.duplicable? returns true if object.dup is safe. False for nil, true, false, symbols, and numbers; true otherwise. References #9333.
|
| Line | |
|---|
| 1 |
class Object |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
def duplicable? |
|---|
| 5 |
true |
|---|
| 6 |
end |
|---|
| 7 |
end |
|---|
| 8 |
|
|---|
| 9 |
class NilClass |
|---|
| 10 |
def duplicable? |
|---|
| 11 |
false |
|---|
| 12 |
end |
|---|
| 13 |
end |
|---|
| 14 |
|
|---|
| 15 |
class FalseClass |
|---|
| 16 |
def duplicable? |
|---|
| 17 |
false |
|---|
| 18 |
end |
|---|
| 19 |
end |
|---|
| 20 |
|
|---|
| 21 |
class TrueClass |
|---|
| 22 |
def duplicable? |
|---|
| 23 |
false |
|---|
| 24 |
end |
|---|
| 25 |
end |
|---|
| 26 |
|
|---|
| 27 |
class Symbol |
|---|
| 28 |
def duplicable? |
|---|
| 29 |
false |
|---|
| 30 |
end |
|---|
| 31 |
end |
|---|
| 32 |
|
|---|
| 33 |
class Numeric |
|---|
| 34 |
def duplicable? |
|---|
| 35 |
false |
|---|
| 36 |
end |
|---|
| 37 |
end |
|---|