From: Tasos Laskos Date: 2010-06-23T03:03:54+09:00 Subject: Re: Help with Ruby return types and documentation Richard Conroy wrote: > On Tue, Jun 22, 2010 at 4:59 PM, Tasos Laskos > wrote: >> >> And of course I did all those things, I'm not an imbecile and I'm also >> not bashing Ruby. >> >> I'd really like not to use IRB just to figure out an inheritance >> hierarchy or the available method/attributes of an object. >> >> > Hi Tasos, > I came from Java like yourself, so the absence of return type > documentation really > warped my head too, to start with. You really can't expect Ruby authors > to > document > return types like they do in Java - a Ruby method can return anything > from a > method. > In practice API writers are unlikely to be jerks about it - returned > objects > tend to have > a lot of consistency. > > While you may not like the IRB option, in practice it is your fastest > path > to understanding. > However you should really take a look at awesome_print: > > http://www.rubyinside.com/awesome_print-a-new-pretty-printer-for-your-ruby-objects-3208.html > > Its a Ruby gem that puts pp (pretty print) on steroids, giving you a lot > of > information about > the objects, including its inheritance hierarchy, and the tree structure > of > any Collections. > > There isn't really a shortcut to learning Ruby libraries. Most don't > play > mindgames with > the return types. However HTML inspection APIs like nokogiri will be > returning objects > that represent complex HTML structures. I remember Hpricot being much > the > same. > > Its worth taking the library through IRB (and ap) for 30 minutes or so > with > some test data, > to get a feel for it. > > regards, > Richard. Hi Richard, Thanks a lot for your informative reply. You missed the one about coming from Java --not a big fun-- but I do appreciate its documentation. My background is in C and PHP. PHP is dynamically typed too but the documentation is pretty clear about types and examples. First day of Ruby today so I guess a working spider and half working analyzer isn't too bad of a progress. I just have to get used to doing things the Ruby way, which I will eventually...unfortunately patience is not one of my qualities. What might have sounded like hostility is actually eagerness. :) Funny you should mention pretty_print and the like, I was just reading about it. That should be a great help for me. Time to setup awesome_print and get cracking with IRB. Thanks again. :) -- Posted via http://www.ruby-forum.com/.