Point = Struct.new(:x, :y)
m = {Point.new(42, 5) => "Hello"}
Map<Point, String> m = {};
m[Point(42, 5)] = "Hello";
m := map[Point]string{}
p := Point{x: 42, y: 5}
m[p] = "Hello"
type Point = (Integer, Integer)
m :: Map.Map Point String
m = Map.empty
m' = Map.insert (42, 5) "Hello" m
Map<Point, String> m = new HashMap<>();
m.put(new Point(42, 5), "Hello");
type
TKey = record
x, y: Integer;
class operator =(L,R: TKey): Boolean;
class operator <(L,R: TKey): Boolean;
class operator >(L,R: TKey): Boolean;
end;
TMap = specialize TFPGMap<TKey, String>;
var
m: TMap;
Key: TKey;
begin
Key.x := 42;
Key.y := 5;
m := TMap.Create;
m.Add(Key, 'Hello World');
m.Free;
end.
my %m;
my $p = Point->new(x => 42, y => 5);
$m{$p} = 'Hello';
m = dict()
p = Point(x=42, y=5)
m[p] = 'Hello'
Point = namedtuple('Point', 'x y')
p = Point(42, 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'}
let mut map: HashMap<Point, String> = HashMap::new();
map.insert(Point { x: 42, y: 5 }, "Hello".into());