Robert,
In looking over the code samples you provided:
------------
def add_edge(from, to)
(@nodes[from] ||= []) << to
self
end
def edges(node_id)
@nodes[node_id] || []
end
def node(node_id)
Node.new(self, node_id)
end
end
------------
I find I am a puzzled:
Even given that to, from are fixnums:
1) what does "@nodes[node_id] || []" return?
2) same question for: "@nodes[from] ||= []) << to"
I could find no reference to this " ||= " syntax (in Pickax, or
other ruby texts, nor online Nor do I understand it's semantics...
3) how about Node.new(self, node_id) I have trouble with the use of
"self" here, the whole usage of "self" has caused me confusion, ever
since I started playing with OO (back when java was IT!)
Thanks,
Chuck
--
Posted via http://www.ruby-forum.com/.