From: sabbyxtabby@... (Sabby and Tabby) Date: 2003-03-11T22:30:49+09:00 Subject: Re: $0 false ?? Eric Hodel wrote: > Sabby and Tabby (sabbyxtabby@yahoo.com) wrote: > > > And, an off-topic challenge: anyone know how to get $0 to return the > > current time? > > > > puts $0 # Mon Mar 10 02:21:26 PST 2003 > > sleep 10 > > puts $0 # Mon Mar 10 02:21:36 PST 2003 > > uhhh.... why would you want that? That's totally silly > > use Time.now Why would anyone want to climb Mt. Everest? It's a challenge! :) Yes, returning the current time is silly. Perhaps returning Apache.Request.filename is less silly. The idea is to have $0 invoke a method to return a calculated value, something akin to Perl's tie() mechanism. A quick search turns up StringMixin in MetaRuby. Unfortunately, #puts only calls #to_s on non-String objects. And $0 can only be assigned a String/subclass -- is $0 an example of a typed variable in Ruby? Admittedly, the challenge is probably impossible for $0, but doable for normal variables. -- Tabby