From: James Britt Date: 2006-05-01T23:17:15+09:00 Subject: Re: More explicit Ruby code Brad wrote: > I'm not a long time Ruby coder, but I have coded for quite some time. I > wanted to ask the groups' opinion on being more explicit with Ruby code. > I like to code like this: > > Kernel.puts("Print this string") > > instead of this: > > puts "Print this string" > > To me, the first version is easier to read as I know where puts is > coming from (Kernel) and what it is encapsulating. I just wonder what > more experienced Ruby coders think of this? What would they think if > they saw several hundred lines of code written this way? Do most find > this type of explicitness unnecessary? You write code to express ideas and intentions to other developers. That includes your future self. If you have reason to think this amount of information is appropriate, then go for it. But I suspect that, fairly soon, you'll internalize many Rubyisms, and then leaving out implicit receivers will seem to enhance, not degrade, communication. If you think that that readers may have a problem with your code, it may be sufficient to leave comments explaining that all methods have a receiver, but in many cases the receiver may be omitted because the Ruby interpreter is smart enough to infer the correct one. And include a link to a basic tutorial. The Ruby ground rules are fairly easy to pick up. There are subtleties in their application, of course, but most people do not need much reminder for common cases. -- James Britt http://www.ruby-doc.org - Ruby Help & Documentation http://www.artima.com/rubycs/ - The Journal By & For Rubyists http://www.rubystuff.com - The Ruby Store for Ruby Stuff http://www.jamesbritt.com - Playing with Better Toys http://www.30secondrule.com - Building Better Tools