Logo

Programming-Idioms

Create a new bidirectional map bm and insert the pair (42, "forty-two")
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
BiMap<Integer, String> bm = HashBiMap.create();
bm.put(42, "forty-two");
import bidict
bm = bidict.bidict({42: 'forty-two'})