Okay, so just out of curiosity, is there a reason why you would ever want to use Object#cloneon a frozen object? As far as I understand, the only reason for using Object#dupit Object#cloneis to get a second copy of an existing object so that you can change it without changing the original. But it Object#clonecopies the frozen state of the object, and you cannot change the frozen objects, so is there any reason why you would ever want to use it in this context?
Object#clone
Object#dup
And according to the corresponding note, if there is no precedent, is there a reason for this?
f = "Some string" f.frozen? #=> false f.freeze f.frozen? #=> true f2 = f.clone f2.frozen? #=> true f2.equal? f #=> false # Why bother? You can't change f or f2 anyway, so # why even copy it at all?
( ) .clone , , .
.clone
, , , , .clone, . , .clone, ( dup ). , - .
dup
, , Ruby, .clone . DSL, , .clone d , , Sinatra, Rails, Grape ..
. , , . DSL, . , , .clone .
Source: https://habr.com/ru/post/1543587/More articles:Rounding to significant digits - Missing zeros - javascriptLimit EventLogs by date - c #Canvas, shape animation along a square path using a sine wave - javascriptCGFloat for NSString with decimal precision, only if there is a fractional part - iosHow to add html DOM Element to canvas using create js - javascriptCloned checked flag undefined property - javascriptLaravel в Apache получает значение заголовка - phpHow to sort an attribute based on some attribute of an element EFFECTIVELY - optimizationConditional action in a macro - vimSeveral aviary feathers - javascriptAll Articles