Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
spuun opened this issue Apr 20, 2023 · 0 comments
Open

Comments

@spuun
Copy link

spuun commented Apr 20, 2023

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}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants