Skip to content

Log::Metadata#extend should append not prepend data (like e.g. NamedTuple#merge) #13360

@spuun

Description

@spuun

Similar data structures and similar methods should behave in the same way.

Log::Metadata#extend(other) will put other first in the new Metadata instance, which is unexpected consider how other similar methods like NamedTuple#merge and Hash#merge works.

a = {a: 1, b: 2}
b = {c: 3, d: 4}

a_b = a.merge(b)
puts a_b # => {a: 1, b: 2, c: 3, d: 4}

require "log"
md_a = Log::Metadata.build(a)
md_a_b = md_a.extend(b)

puts md_a_b.to_h # => {:c => 3, :d => 4, :a => 1, :b => 2}

I'd expect the latter to print {:a => 1, :b => 2, :c => 3, :d => 4}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions