How do I call a method that is a hash value?

前端 未结 7 724
后悔当初
后悔当初 2021-01-07 02:47

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 respons

7条回答
  •  悲&欢浪女
    2021-01-07 03:24

    a = ->(string="No string passed") do

    puts string

    end

    some_hash = { 0 => a }

    some_hash[0].call("Hello World")

    some_hash[0][]

提交回复
热议问题