Hal Fulton wrote: > Florian Gross wrote: > >> >> See attachment. ;) >> > > Florian, > > This seems pretty cool, and could revolutionize the way Rubyists > write Javascript. :) > > But I would enjoy seeing some sample code showing what you can do, > some warnings about what you can't do, and some docs in general. Maybe I can do something like that in the future -- for now it seems to be a bit too time consuming. Here's a few simple samples: [1, 2, 3].each(function(item) { alert(item * 2) }) [1, 2, 3].map(function(item) { // The return is needed. functions don't return their last expression // by default. return(item * 2) }).each(alert) // Functions can be supplied directly instead of blocks. 1.succ() // This doesn't work -- 1.0.succ() // use either this (1).succ() // or this Also note that you can't omit the parentheses of a method call in JavaScript which is by design of course, but takes some getting used to. Some bigger differences that come to mind: Array#each always yields value, index. This is no problem in JavaScript, because a function that takes one argument will not get an Array of arguments when you give multiple arguments to it. There's no Enumerable#each_with_index because of the above. Hash#each yields value, key. This makes things much easier, because it the key can be handled as an index. (So there's a symmetry between Array#each and Hash#each) Ranges don't work as well as I'd wish them to right now. I wanted to make it possible to also have reverse Ranges like 10 .. 4, but that doesn't work too well with Strings. String#ljust doesn't work with filler Strings that are longer than one character right now. I hope that this library of some use even if there is no complete documentation (yet). And thank you for the positive feedback! Regards, Florian Gross