From: matz@... Date: 2016-11-25T08:59:55+00:00 Subject: [ruby-core:78337] [Ruby trunk Feature#12719][Feedback] `Struct#merge` for partial updates Issue #12719 has been updated by Yukihiro Matsumoto. Status changed from Open to Feedback I want to see a real-world use-case for the feature. In addition, I don't think the name `merge` is the best for the functionality. Matz. ---------------------------------------- Feature #12719: `Struct#merge` for partial updates https://bugs.ruby-lang.org/issues/12719#change-61701 * Author: Matthew Mongeau * Status: Feedback * Priority: Normal * Assignee: ---------------------------------------- Other languages have operators for performing partial updates on maps. I feel like Struct could be more useful if it provided an easy way of performing partial (or full) updates. After the change you can do the following: ~~~ ruby Point = Struct.new(:x, :y) p = Point.new(1, 2) p2 = p.merge(y: 4) p3 = p2.merge(x: 10) p.inspect # => # p2.inspect # => # p3.inspect # => # p.merge!("x" => 9) p.inspect # => # ~~~ ---Files-------------------------------- struct_merge.patch (2.93 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: