From: yamataka@...08.itscom.net Date: 2018-03-22T10:00:30+09:00 Subject: [ruby-list:50655] [質問] 関数内にて引数に渡された変数の変数名を取得 山口と申します。 yama@roswell:~$ uname -a CYGWIN_NT-6.1 JPC20316739 2.10.0(0.325/5/3) 2018-02-02 15:16 x86_64 Cygwin yama@roswell:~$ ruby -v ruby 2.3.6p384 (2017-12-14 revision 9808) [x86_64-cygwin] last_commit=ruby 2.3.3 の環境で、下記のコードにて、 music = { ex1: 'Play the top pop station' } def tbl_say(tbl,ex) unless tbl.has_key?(ex) puts "[ERROR] #{ex} is not in #{tbl}" end end tbl_say(music,:ex1) tbl_say(music,:ex2) # [ERROR] ex2 is not in {:ex1=>"Play the top pop station"} # ではなく # [ERROR] ex2 is not in music と表示させたい tbl_say関数の引数、tblに渡された music の変数名を取得したいのですが よい記述方法があれば、ご教示いただけないでしょうか