3 ms·
Here's a fun example. Matz (creator of Ruby) contributed a chapter to Beautiful Code (the O'Reilly book). In it, he uses this example of a Rake task as his exam
by jashkenas 16y ago
Here's a fun example. Matz (creator of Ruby) contributed a chapter to Beautiful Code (the O'Reilly book). In it, he uses this example of a Rake task as his example of a beautiful piece of Ruby:
task :default => [:test]
task :test do
ruby "test/unittest.rb"
end
Let's see what that could look like in CoffeeScript, assuming a similar library:
task default: ['test']
task 'test', ->
ruby 'test/unittest.rb'
Pretty nice. Running that through the CoffeeScript compiler produces this JavaScript:
task({
"default": ['test']
});
task('test', function() {
return ruby('test/unittest.rb');
});