From: Ryan Leavengood on
On 5/3/07, Rick DeNatale <rick.denatale(a)gmail.com> wrote:
>
> After seeing the neat use of each_slice instead of each_with_index
>
> def luhn(string)
> string.scan(/./).reverse.enum_for(:each_slice, 2).inject(0) do |sum, (d1, d2)|
> sum += d1.to_i + (d2||'0').tr('0123456789', '0246813579').to_i
> end % 10 == 0
> end
>
> No need to define any extra Enumerator methods.

Nice, I like it. When I first thought about using
enum_for(:each_slice, 2) I was surprised that it even worked.
Enumerator is a powerful library.

It seems like I learn something new every time I do one of these
quizzes, either from making my own solution or reading someone else's.

Ryan

From: James Edward Gray II on
On May 3, 2007, at 9:15 AM, anansi wrote:

>> Ruby Quiz will now take a one week break. Work has been rough
>> this week and I
>> need some down time. I'll be back next week, rested, and with new
>> quizzes...
>
>
> Means that: no quiz tomorrow ?!?

Yes. I need a short break. We will have one the following Friday
though.

James Edward Gray II

From: Rick DeNatale on
On 5/3/07, Ryan Leavengood <leavengood(a)gmail.com> wrote:

> Enumerator is a powerful library.

Yep. And personally, I like the fact that Ruby 1.9 is on the path to:

1) Move enumerator to the core classes.
2) Have enumerator methods return an enumerator if they are called
without a block.

The second one seems to be slightly controversial, but I love it.

--
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

From: anansi on
James Edward Gray II wrote:
> On May 3, 2007, at 9:15 AM, anansi wrote:
>
>>> Ruby Quiz will now take a one week break. Work has been rough this
>>> week and I
>>> need some down time. I'll be back next week, rested, and with new
>>> quizzes...
>>
>>
>> Means that: no quiz tomorrow ?!?
>
> Yes. I need a short break. We will have one the following Friday though.
>
> James Edward Gray II
>



Maybe someone is interested or has an idea for an unoffical Ruby Quiz
for this week. I'm bored , so If someone has any idea, feel free to drop
it ;)



--
greets

(
)
(
/\ .-"""-. /\
//\\/ ,,, \//\\
|/\| ,;;;;;, |/\|
//\\\;-"""-;///\\
// \/ . \/ \\
(| ,-_| \ | / |_-, |)
//`__\.-.-./__`\\
// /.-(() ())-.\ \\
(\ |) '---' (| /)
` (| |) `
jgs \) (/


one must still have chaos in oneself to be able to give birth to a
dancing star
From: Puria Nafisi Azizi on
anansi wrote:
> Maybe someone is interested or has an idea for an unoffical Ruby Quiz
> for this week. I'm bored , so If someone has any idea, feel free to drop
conway's game of life?