クラスがある場合:
class KlassWithSecret
def initialize
@secret = 99
end
end
そして実行します:
puts KlassWithSecret.new.instance_eval { @secret }
それは99を出力しますが、実行すると:
puts KlassWithSecret.new.instance_eval do
@secret
end
エラーが返されます。`instance_eval': wrong number of arguments (0 for 1..3) (ArgumentError)
で do/end ブロックを使用できないのはなぜinstance_eval
ですか?
PS私はRuby 2.1.0を使用しています。