Comment

Comment by zevyoura

But this is wrong in at least two ways:

> Additionally, if the hash contains duplicate keys, swapping the keys and values may not have the desired effect.

You can't have duplicate keys in a hash.

More importantly, their implementation adds the swapped pairs but does not remove the original k/v pairs, which is both incorrect and does not match the output it prints.

parent zevyoura 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton