As my knowledge of Object#send stands now: it can't recreate the full
breadth of method invocations in ruby. Object#send should accept an
optional parameter:

[1,2,3].send(:collect, :block => lambda{|x| x.to_s+"!"})

That obviously wouldn't work because it's still ambiguous. Oh well.
I'll just extend the nokogiri class! Thanks for playing everyone!

Xavier

On Mon, Jan 31, 2011 at 9:49 PM, Kevin Clark <[email protected]> wrote:
> Yeah, doesn't matter if you could curry it or not - it needs to be
> passed as a block. If you don't separate them, there's no way to
> detect it *should* be separated. *args can't work. That's why method
> missing takes them separate - blocks are considered their own part of
> the call, and you only get one.
>
> On Mon, Jan 31, 2011 at 7:43 PM, Jordan Fowler <[email protected]> wrote:
>> Oh wait, I missed the part about needing an anonymous block. Hmm...
>>
>> On Mon, Jan 31, 2011 at 7:41 PM, Jordan Fowler <[email protected]> wrote:
>>>
>>> You can also use a lambda:
>>> ruby-1.9.2-p136 :004 > [:collect, lambda { |x| x.to_s + "!" }]
>>>  => [:collect, #<Proc:0x000001009a29b8@(irb):4 (lambda)>]
>>> On Mon, Jan 31, 2011 at 7:34 PM, Kevin Clark <[email protected]>
>>> wrote:
>>>>
>>>> > Ben,
>>>> >
>>>> > So that works when it's being passed directly to send but it won't
>>>> > work when passed in from a splatted array!
>>>> >
>>>> >    [1,2,3].send(*[:collect, &Proc.new{|x| x.to_s + "!"}])
>>>> >    -> SyntaxError: (irb):1: expecting ']'
>>>>
>>>> That doesn't work because you can't put a block in an array:
>>>>
>>>> >> [:collect, &Proc.new{|x| x.to_s + '!'}]
>>>> SyntaxError: compile error
>>>>
>>>> Instead of storing the call and args in an array, you might want to
>>>> consider a hash so you can label and handle blocks special case.
>>>> There's some ambiguity in just shoving it in at the end of the args
>>>> (is it a user argument or a handler?).
>>>>
>>>> --
>>>> Kevin Clark
>>>> http://glu.ttono.us
>>>>
>>>> --
>>>> SD Ruby mailing list
>>>> [email protected]
>>>> http://groups.google.com/group/sdruby
>>>
>>>
>>>
>>> --
>>> Jordan A. Fowler
>>> E-mail: [email protected]
>>> Website: http://www.jordanfowler.com
>>> Phone: (619) 339-6752
>>>
>>
>>
>>
>> --
>> Jordan A. Fowler
>> E-mail: [email protected]
>> Website: http://www.jordanfowler.com
>> Phone: (619) 339-6752
>>
>> --
>> SD Ruby mailing list
>> [email protected]
>> http://groups.google.com/group/sdruby
>
>
>
> --
> Kevin Clark
> http://glu.ttono.us
>
> --
> SD Ruby mailing list
> [email protected]
> http://groups.google.com/group/sdruby

-- 
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to