LoginSignup
0
0

More than 1 year has passed since last update.

標準出力で値確認するときに便利な書き方

Posted at

Proc.new{|statement| puts "#{statement}: #{eval(statement)}"}.call(値を確認したい式)

irb(main):001:0> hoge = {a: 1}
irb(main):002:0> Proc.new{|statement| puts "#{statement}: #{eval(statement)}"}.call("hoge[:a]")
hoge[:a]: 1

puts "hoge[:a]: #{hoge[:a]}"でもいいんだけど、毎回2回コピペするのが面倒なので1度で済むように書きました

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0