binds a class-prototype-method func (by reference) to the passed object self (which should be an instance of the class), and returns that bound method.
Example
typeID = number constgraph_edges = newMap<ID, Set<ID>>() constset_graph_edge = bindMethodToSelf(graph_edges, graph_edges.set) // automatic type inference will correctly assign it the type: `(key: number, value: Set<number>) => Map<number, Set<number>>` constedges: [ID, ID[]][] = [[1, [1,2,3]], [2, [3,5]], [3, [4, 7]], [4, [4,5]], [5, [7]]] for (const [id, adjacent_ids] ofedges) { set_graph_edge(id, newSet(adjacent_ids)) }
binds a class-prototype-method
func
(by reference) to the passed objectself
(which should be an instance of the class), and returns that bound method.Example
example with assigned default arguments