Legend - thanks!
Sonia Hamilton.
Lachie wrote:
> Hi Sonia,
>
> ActiveSupport extends Object with the #tap method (backported if
> necessary from ruby 1.9/1.8.7) for this exact purpose:
>
> number.scan(/./).map do |digit|
> digit(SpecialDigits[digit] || digit, size)
> end.
> tap {|result|
> # probe here!
> pp result
> }.
> transpose.map do |line|
> line.join(" ")
> end.join("\n")
>
> HTH
> :lachie
> http://plus2.com.au
> http://smartbomb.com.au
> http://www.flickr.com/photos/lachie/
>
>
>
> On Fri, Oct 2, 2009 at 6:33 PM, Sonia Hamilton <[email protected]> wrote:
>
>> Hi everyone, more of a Ruby (vs Rails) question.
>>
>> I'm debugging this piece of code (using rdebug). It works but I'm just
>> digging around, understanding it and rdebug better:
>>
>> 51 number.scan(/./).map do |digit|
>> 52 digit(SpecialDigits[digit] || digit, size)
>> 53 end.transpose.map do |line|
>> 54 line.join(" ")
>> 55 end.join("\n")
>>
>> Here's my question: how would I get the result of the first map? ie the
>> resulting array that's been built up by the time the 'end' is reached on
>> line 53, but before it enters into the tranpose.map on line 53.
>>
>> I could break the code apart into 2 sections ie
>>
>> 51 result = number.scan(/./).map do |digit|
>> 52 digit(SpecialDigits[digit] || digit, size)
>> 53 end
>> 53b result.transpose.map do |line|
>>
>> and examine the contents of result. But I'm wondering if there's a
>> better way....
>>
>> --
>> Sonia Hamilton.
>> http://twitter.com/sonia_hamilton
>> http://soniahamilton.wordpress.com
>> http://www.linkedin.com/in/soniahamilton
>>
>>
>>
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
or Rails Oceania" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rails-oceania?hl=en
-~----------~----~----~----~------~----~------~--~---