From: Wesley J Landaker Date: 2003-12-05T10:20:17+09:00 Subject: Re: Generalized break? --Boundary-02=_O19z/3OO9Vr/u5/ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline On Thursday 04 December 2003 5:32 pm, Ara.T.Howard wrote: > > 2. I have a mild dislike for the idiom if $0 =3D=3D __FILE__ (lines) > > end -- because I always indent inside an if, and I don't want to > > indent, and I really just want to say: break if $0 !=3D __FILE__ > > agreed. > > how about something like > > __TEST__ > > for this? Ooohh, I like that! =3D) (Hmmm... can we implement it in ruby as is? ... using the eval hack=20 posted earlier in this thread sort of works, although this is a bit=20 ugly): =2D-- test.rb --- #!/usr/bin/ruby def __TEST__(file) if $0 =3D=3D file eval DATA.readlines.join("\n"), binding, file end end =2D-- demo.rb --- #!/usr/bin/ruby #!/usr/bin/ruby require 'test' puts "1" __TEST__(__FILE__) __END__ puts "2" Then: $ ./demo.rb 1 2 $ irb irb(main):001:0> require 'demo' 1 =3D> true Not sure how to get around passing __FILE__ in, or having __END__ there=20 as well... =2D-=20 Wesley J. Landaker - wjl@icecavern.net OpenPGP FP: 4135 2A3B 4726 ACC5 9094 0097 F0A9 8A4C 4CD6 E3D2 --Boundary-02=_O19z/3OO9Vr/u5/ Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQA/z91O8KmKTEzW49IRApUqAJ9nvSwfKj94tFT5zawIGfLPgtpgjgCfTv3C ZDvXhW4m2+F1tqC597XZi0w= =Ck+9 -----END PGP SIGNATURE----- --Boundary-02=_O19z/3OO9Vr/u5/--