From: gwtmp01@... Date: 2006-08-11T10:56:45+09:00 Subject: Re: Referring to an instance method using a variable On Aug 10, 2006, at 9:33 PM, Jos Backus wrote: > This is what I have come up with: > > lizzy:~% cat rtest > OPS = { > '=' => proc { |a, b| return a == b ? 1 : 0 }, > '==' => proc { |a, b| send(:equals, a, b) }, > } > > def equals(a, b) > return a == b ? 1 : 0 > end > > puts OPS['='].call(1, 1) > puts OPS['=='].call(1, 2) > lizzy:~% ruby rtest > 1 > 0 > lizzy:~% Is there supposed to be a semantic difference between the '=' and '==' operator in what you are trying to accomplish or are you just trying to implement '=' as a proc and '==' as a method? Does this help at all? def equals(a, b) return a == b ? 1 : 0 end OPS = { '=' => proc { |a, b| return a == b ? 1 : 0 }, '==' => method(:equals), } puts OPS['='].call(1, 1) puts OPS['=='].call(1, 2) Gary Wright