假设我有:
def foo(bar, baz)
puts "Called foo, bar = #{bar}, baz = #{baz}"
blah_blah
end
我可以为这样的编辑器宏做些什么:
def foo(bar, baz)
puts "<the answer to this question>"
blah_blah
end
获得相同的调试结果?
答案 0 :(得分:0)
方法中有一些元信息:
def foo(bar, baz=2)
p __method__ #=> : foo
p method(__method__).parameters # => [[:req, :bar], [:opt, :baz]]
end
foo( 1, 2)
def foo(a: "bar",b: )
p method(__method__).parameters # => [[:keyreq, :b], [:key, :a]]
end
foo(a: 1,b: 2)