From: Michael Lucas-Smith Date: 2001-06-15T14:10:56+09:00 Subject: [ruby-talk:16486] Initial thoughts about Ruby From a Smalltalk Programmer Hi Everyone, I have to say I'm utterly fascinated by Ruby and I'm really getting in to the spirit of it. I've been programming in Smalltalk for about three years now. Some of the things that initially hit me with Ruby though: Procs, Blocks - a confusion. It is really nice to be able to throw around a block to methods and get it's value using yield. But there is a limitation that to pass more than one block to a method you need to convert it in to a Proc. One of the most comment extensions to Smalltalk that you might find is this: Collection>>detect: detectBlock ifFound: foundBlock ifNone: noneBlock To write something similar in Ruby as of 1.6.4, you end up writing: class Array def found_none(found_proc,none_proc) return none_proc.call if !(result = detect) result end end a = [1,2,3,4] a.found_none (proc {|e| print e}, proc {print 'none'}) {|e| e == 3} this isn't ideal. In fact, it's disguisting. Especially since you can't pass your Proc's on as block's to be the next yieldable block. You need to write a block that evaluates the proc to be your block. My next thought was with formatting method parameters # this works method parameters # this doesn't method ( parameters) # this works method (parameters) # this doesn't method {someCode} # this works method {someCode} # this doesn't why am I going on about this? someCollection found_none (proc {|e| print e}, proc {print 'none'}) {|e| e == 'testing'} is much easier to read than: someCollection found_none ( proc {|e| print e}, proc {print 'none'}) {|e| e == 'testing'} Am interested to hear peoples opinions on my first experiences with Ruby Michael Lucas-Smith