Edward Kenworthy
2/12/2006 10:03:00 PM
Thanks for all that David :-)
On 12 Feb 2006, at 18:41, David Vallner wrote:
> Dna Nedela 12 Február 2006 18:38 Edward Kenworthy napísal:
>> Hi All
>>
>> I've been programming for more years than I care to remember and am
>> enjoying programming in Ruby (especially on Rails). So far I've found
>> nothing "new" (to me) in Ruby, with the exception of the lisp-like
>> features and that's something I'd really like to explore.
>> Unfortunately, unless I've overlooked it, neither the pick-axe book
>> nor "the ruby way" seem to cover this. I'm particularly interested
>> in which common problems these features let me solve in a more
>> elegant and concise way than using regular structured/oo approaches.
>>
>> Anyone able to point me to a resource please?
>>
>> Edward
>
> Well, Ruby is a strongly derivative language, there's not THAT much
> in terms
> of new and exciting features around. It's more about picking out
> which you
> think are nifty and which not.
>
> As for the lisp-like operations, I'd say the blocks as lexical
> closures are a
> notable one. Not very often used as such, but they are somewhat
> useful when
> you want to develop your own control structures, As Seen In
> Smalltalk (tm).
>
> I'd also put collection mapping / filtering using blocks as one.
> Which pretty
> much reduces the messy nested loops that you end up with when
> trying to do
> this in lessay Java into in my opinion much neater method chains.
> And then
> there's also Enumerable#inject, the swiss knife of collection
> operations,
> which lets you do pretty much everything. Cf. my favourite #inject
> example, a
> very cryptic O(n)n factorial:
>
> class Integer
> def factorial
> (1..self).inject(1){|m, n| m * n}
> end
> end
>
> I also think strongtyping.rb lets you do something along the lines
> of poor
> man's multimethods. Or rather method overloading based on runtime
> types
> instead of compile-time.
>
> David Vallner
>