From: Martin Martinos Date: 2007-10-04T23:14:50+09:00 Subject: Re: File scope variable Robert Klemme wrote: > 2007/10/3, Martin Martinos : >> >> example: >> >> require 'pathname' >> my_path = Pathname.new(__FILE__).realpath.dirname >> >> require my_path +'mylib' >> >> def exec_my_bin() >> `#{my_path + 'bin/mybin'}` >> end > > What is wrong with this solution? my_path *is* visible in the current > file only as far as I can see. Btw, what are you trying to achieve? > > Kind regards > > robert In fact, it only visible in the current file but it's not visible in the exec_my_bin() function and I don't want to write: def exec_my_bin() `#{Pathname.new(__FILE__).realpath.dirname + 'bin/mybin'}` end Also I don't want to use a global variable, which I think is a bad idea since I don't want to use it in another file. Thanks -- Posted via http://www.ruby-forum.com/.