Hi All,

After reading Justin's last post (http://encytemedia.com/blog/articles/2006/07/05/writing-custom- iterators-for-prototype) where he uses the following piece of code:

var tags = "div p span ul ol li span form input select textarea h1 h2 h3 h4 h5 h6 dl dt em strong";

$A(tags.split(' ')).each(function(tag) {
   //do something
 });

I came to realize that Prototype could possibly do with a three liner add-on for even more syntactic sugar:

function $w(string){
  return string.split(/\s+/);
}

which just is a javascript implementation of the ruby flavored %w{ ant bee cat dog elk } and which would enable, for example, the following:

$w("ant bee cat dog elk ").each(function(animal){
  alert(animal);
});

What do you think? Is it overkill or should I just go ahead and post an enhancement patch?

Any suggestions welcomed...

Regards,

Tobie

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to