Trans
2/3/2005 6:22:00 AM
E S wrote:
> In my current project, one of the main paradigms is code such as in
> the following example. I'm wondering if there's a Ruby/OO designation
> for it so that I wouldn't have to always show some excerpt when
> describing the project. It's sort of an inverse continuation passing
> scheme (which, in itself, isn't exactly a prime OO term).
>
>
> def three()
> return lambda { |s1, s2| puts s1 + s2 }
> end
>
> def two()
> return lambda { |s1| three().call(s1, 'world!') }
> end
>
> def one()
> return lambda { two().call('Hello ') }
> end
>
> one().call # "Hello world!"
>
>
> Anything? Input on the style welcome, too, by the way: is this hard
to
> understand/unintuitive/there's a better way/etc.?
def three
lambda { |s1, s2| puts s1 + s2 }
end
def two
lambda { |s1| three[s1, 'world!'] }
end
def one
lambda { two['Hello '] }
end
one[] # "Hello world!"
But why do?
T