From: Daniel Amelang Date: 2005-04-06T12:11:22+09:00 Subject: Re: Garden RubyNuby Question on parameters in blocks vs. methods > I'm suprised that no one is offering an answer here, especially > considering what's being said about the community's support of Nuby's > in other threads. Sorry, Trans, I just think that there are so many people on this list that everyone figures someone else will answer. That said, your original post isn't _that_ old. If you're looking for real-time help, go to #ruby-lang on irc.freenode.net. > Well, I'll take a small stab at the 2nd. Please correct me in so far as > I am wrong: In future versions of Ruby block parameters and def > parameters will work exaclty alike. Although I think 1.9 will make them work more similarly that they do now, I don't think they will ever work exactly alike. You can do some stuff with block parameters that's pretty crazy. For example, you don't have to 'accept' the arguments passed in: def doit yield(1) end doit { puts "Look ma, no arguments!" } And you can expand arrays: def pass_array yield([1,2]) end pass_array {|(first, second)| puts "First element: #{first}"} I haven't seen anything that says that methods will have this same behavior (although they can do some of the same things using different syntax) Anyone else? > As for the first. Why not "do (a,b) ... end" instead of "do |a,b| ... > end" Well, without thinking about it to much, I imagine it is simply > due to syntax ambiguities. I've wondered about this one before. It would be _possible_ to change the method definition to use pipes instead of parans, and not have ambiguities (I think), but that's a pretty significant language change. I guess they were just born that way, and it's too late to change. So, anyone else? Dan