On Aug 16, 1:20 pm, "Chris Carter" <cdcar... / gmail.com> wrote:
> On 8/16/07, dbl... / rubypal.com <dbl... / rubypal.com> wrote:
>
> > You could do this (and I think it's similar to the "once" technique
> > [pattern?] that's used in the Date library and talked about in the
> > Pickaxe):
>
> >    def my_time
> >      t = Time.now
> >      (class << self; self; end).class_eval do
> >        define_method(:my_time) { t }
> >      end
> >      t
> >    end
>
> Why not just use a closure, and do it the way you would in JS?
>
> foo = proc { x=Time.now; foo = proc { x } }; foo.call
>
> Then you just access it with foo[]/foo.call
>
> --
> Chris Carter
> concentrationstudios.com
> brynmawrcs.com

I also thought of it.
But foo.call isn't so good.
I think JavaScript's syntax is better than ruby's about returning a
function.

Sam