jcoglan wrote:
> Hello all,
>
> I've just released a bit of code I'm calling 'Reiterate' that aims to
> allow you to use strings, arrays and hashes where you'd normally use
> iterator functions in Enumerable methods. Think of what 'pluck' and
> 'invoke' do, but applied to lots of other methods.
>
> ...
> http://dev.rubyonrails.org/ticket/9611.
This is totally sweet. I've often fleetingly wondered if it would be
possible to create iterators from strings. This is really creative and
intuitive. I'm not from the Ruby world, but I love it!
My only suggestion would be to require an explicit call #toFunction() so
that it would be more obvious that it is an iterator function and not
require an extra line be added to the Enumerable functions. (if
(iterator) iterator = Function.from(iterator); )
So, for example:
['FOO', 'BAR', 'BAZ'].map('toLowerCase.toArray'.toFunction());
var divs = someDivs.findAll($H({hasClassName: 'myClass', visible:
true}).toFunction());
['apples', 'oranges', 'plums'].sortBy(['replace', /^(..)(.)/,
'$2$1'].toFunction());
What do you think?
- Ken Snyder
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---