に変換、自分でそれを試してみることができますように
class << foo = BasicObject.new
def method_missing(meth, *args)
$>.puts "`foo.#{meth}(#{args.inspect[1...-1]})`"
end
BasicObject.instance_methods.each(&method(:undef_method))
end
print '`foo.(1, 2, 3)` gets translated to '
foo.(1, 2, 3)
# `foo.(1, 2, 3)` gets translated to `foo.call(1, 2, 3)`
print '`not foo` gets translated to '
not foo
# `not foo` gets translated to `foo.!()`
print '`+foo` gets translated to '
+foo
# `+foo` gets translated to `[email protected]()`
print '`~foo` gets translated to '
~foo
# `~foo` gets translated to `foo.~()`
print '`foo[1, 2, 3] = 4` gets translated to '
foo[1, 2, 3] = 4
`foo[1, 2, 3] = 4` gets translated to `foo.[]=(1, 2, 3, 4)`
そして...
をあなたが見ることができるように、foo.(bar, baz)
はfoo.call(bar, baz)
に翻訳されます。
この回答を見てみましょう。 'は配列のインデックスを指す?](http://stackoverflow.com/questions/37067744/can-i-override-digit-to-point-at-an-index-for-an-array/37067983 #37067983) –
AlexN
@potashin Ohh ?!実際にラムダですか?それはクールです:)ありがとう。やってみます。代わりに答えとしてあなたのコメントを入れたいですか? –
@AlexN ok。ありがとう。私はそれをチェックします:) –