From: halogenandtoast@... Date: 2016-09-02T09:27:48+00:00 Subject: [ruby-core:77125] [Ruby trunk Bug#12719] `Struct#|` for partial updates Issue #12719 has been reported by Matthew Mongeau. ---------------------------------------- Bug #12719: `Struct#|` for partial updates https://bugs.ruby-lang.org/issues/12719 * Author: Matthew Mongeau * Status: Open * Priority: Normal * Assignee: * ruby -v: * Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN ---------------------------------------- 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 | { y: 4 } p3 = p2 | { x: 10 } puts p.inspect # => # puts p2.inspect # => # puts p3.inspect # => # ~~~ ---Files-------------------------------- struct_update.patch (2.04 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: