How do I call a method that is a hash value?
问题 Previously, I asked about a clever way to execute a method on a given condition "Ruby a clever way to execute a function on a condition." The solutions and response time was great, though, upon implementation, having a hash of lambdas gets ugly quite quickly. So I started experimenting. The following code works: def a() puts "hello world" end some_hash = { 0 => a() } some_hash[0] But if I wrap this in a class it stops working: class A @a = { 0 => a()} def a() puts "hello world" end def b() @a