From: "Mauricio Fernández" Date: 2003-01-16T02:55:16+09:00 Subject: Re: Ruby advocacy in sigs On Mon, Jan 13, 2003 at 05:50:01AM +0900, Martin DeMello wrote: > Chad Fowler wrote: > > > > Agreed. I'd say the most powerful Ruby advocacy .sig would be something > > to the tune of: > > > > http://www.ruby-lang.org > > Little (72x4) code snippets that were sufficiently eye-catching would be > a nice positive way to do it. Not along the lines of perl's JAPHs, more > like code whose meaning is obvious when you read it, and which is cool > in a "wow - Ruby lets you do it that simply/elegantly/enjoyably?!" sense. > (The Haskell quicksort is a perfect example of the sort of thing I have > in mind). > > Some off-the-top-of-my-head examples (and I'm sure there are several far > better ones) > > def twice; yield; yield; end > twice {print "Hello World"} > > nthreads.times {|i| Thread.new {task[i].call}.join} > #Multithreading Ruby style. This executes the tasks sequentially as you wait for each one to end before starting the next... This works: task.map{ |t| Thread.new{ t.call } }.each{ |thread| thread.join } -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com We come to bury DOS, not to praise it. -- Paul Vojta, vojta@math.berkeley.edu