On Sun, Dec 7, 2008 at 2:53 AM, Nuno Job <[EMAIL PROTECTED]> wrote:
>> if not Object.respond_to? :tap
>>     class Object
>>         def tap
>>             yield self
>>             self
>>         end
>>     end
>> end
>
> This is something that will exist in ruby 1.9. I was using it to create the
> data folder. Slight rewrite from one of your samples:
>
>>   def data_path
>>     @data_path||=lambda do
>>       RUBY_PLATFORM =~ /win32/ ? File.expand_path(Dir.getwd) :
>> File.expand_path(File.join("~", ".rudolph"))
>>     end.call.tap{|udd| Dir.mkdir(udd) unless File.exist?(udd)}
>>   end
>
> This should work. I just defined tap in the source. Anyway it doesn't
>
> The reason it is important for this to work is to make the code work better.
> This way we just do all those calculations if data_path is not present. And
> mkdir something like a sideeffect so it makes sense to be in a tee (tap,
> whatever) clause.
>
>> Object.respond_to?(:tap).to_s
>> => false
>
> Any ideas? I'm still a newbie on shoes :\

How exactly are you defining this extension? i.e. please give a full
example with more context.

-- 
Seth Thomas Rasmussen
http://greatseth.com

Reply via email to