You're probably right in this case (pun intended) but OTOH it did introduce 
the concept nicely as a side-effect of looking at case's cleverness. It 
prompted me to ask a stupid question and thereby learn a little. It made me 
go back and look at C++'s switch statement (see a just-prior posting) and 
feel frustrated that C++ doesn't support such flexibility. (I mean not even 
support the generic object.equals syntax, never mind a closure.) That's the 
kind of thing that highlights why one might bother with Ruby at all. If you 
don't get the cleverness presented to you, you might never find out about 
it.

On Tuesday, August 5, 2014 5:22:31 PM UTC+10, Dan Harper wrote:
>
> On 5 Aug 2014, at 4:24 pm, Tim Moore <[email protected] 
> <javascript:>> wrote:
>
> One thing that hasn't been mentioned yet, and which unfortunately I 
> couldn't really address in the talk without a long tangent, is *why *would 
> you want to write code like this in the first place? Is a proc in a case 
> statement anything but a useless, overly-clever bit of language esoterica?
>
>
> I had the same thought. After some musing, I came to the conclusion that 
> you should opt for simpler code using simple concepts and cop the penalty 
> of it being more verbose. Not everyone will agree I’m sure, and that’s cool.
>
> The advantages of having simpler code using simple concepts is that your 
> code is now more easily understood by other developers with a lower level 
> of Ruby knowledge.  This is the same reason I try to not perform Ruby 
> gymnastics in tests. If I do decide to use some more complex code, I use 
> comments to explain what I’m doing.
>
> This was probably more important back in the day when hardly anyone used 
> Ruby, but I still follow it.
>
> If you’re just consuming gems (not authoring them) and say, coding in 
> Rails, you’ll rarely have a need to use Proc or similar concepts. So when 
> you’re learning, I’d say don’t bother with Proc and fancy Ruby concepts. 
> Learn other things that will get you more productive at a faster rate.
>
> Dan
>
>
> Dan Harper
> [email protected] <javascript:>
> Mobile:  0414 344 233
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rails-oceania.
For more options, visit https://groups.google.com/d/optout.

Reply via email to