Why Ruby?

foobar foo at bar.com
Sun Dec 12 11:44:14 PST 2010


Adam D. Ruppe Wrote:

> foobar wrote:
> > D basically re-writes foreach with opApply into the ruby version
> which is why Ruby is *BETTER*
> 
> You missed the point: there is no "Ruby version". They are the
> same thing.
> 
By "ruby version" I meant the syntax. I agreed already that they are implemented the same. 

> > foreach to me is a redundant obfuscation
> 
> How can it be redundant? It's got the same elements the same
> number of times.
> 
incorrect. The difference is that D adds "special" syntax for this whereas it's just a plain method in Ruby. By calling opApply directly you get the direct "ruby version" without the redundant use of a keyword + compiler transformation. 

> 
> rofl.copter.each |lol|
>     spam
> end
> 
> 
> foreach(lol; rofl.copter)
>     spam
> 
> 
> Same elements, just reordered.
> 
> 
> I don't know about the each() method itself. I've never written
> one, but I suspect it is virtually identical to opApply too.

opApply *is* the same thing as Ruby's each method. 




More information about the Digitalmars-d mailing list