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.
m := map[Point]string{}
p := Point{x: 42, y: 5}
m[p] = "Hello"
m = dict()
p = Point(x=42, y=5)
m[p] = 'Hello'
m = {Point(42, 5): 'Hello'}
class Point:
def __init__(self, x, y):
self.x, self.y = x, y
def __hash__(self):
return hash((self.x, self.y))
def __eq__(self, p):
return self.x == p.x and \
self.y == p.y
m = {Point(42, 5): 'Hello'}
Point = Struct.new(:x, :y)
m = {Point.new(42, 5) => "Hello"}