我正在阅读自信的红宝石,我正在尝试如何定义可重用的过程.从给出的例子中,我写道:
DEFAULT_BLOCK = -> { 'block executed' }
answers = {}
answers.fetch(:x, &DEFAULT_BLOCK)
Run Code Online (Sandbox Code Playgroud)
我期待它返回,block executed因为x在Hash中找不到它,而是返回它wrong number of arguments (given 1, expected 0) (ArgumentError).问题是什么?我还没有给出一个论点.