From: 7stud 7stud Date: 2007-03-13T07:58:13+09:00 Subject: Re: string to int: ruby documentation? Gary Wright wrote: > On Mar 11, 2007, at 11:20 PM, 7stud 7stud wrote: > >> >> I gave Integer() a string and it threw an exception. > > I muddled up a specific response to you about Integer with some > more general observations about exceptions and Ruby. Sorry I wasn't > clear: > > 1) Ruby documentation isn't perfect. You found a problem. > 2) There are methods (i.e. Integer()) where exceptions are part > of the expected behavior of the method and they *should* be > documented. If they aren't, that is a bug not a feature. > 3) Most Ruby methods don't say anything about exceptions because > exceptions are not part of the API of most Ruby methods. There > is an overall assumption that if you call a method without meeting > the pre-conditions then the behavior (including the raising of > exceptions) is undefined. > 4) Pre-conditions should be clearly described by the documentation. > > Gary Wright Ok. I was all set to buy the pickaxe book, but then I noticed that missing documentation, so I decided to look for alternatives. I looked in "The Ruby Way", and it mentions that Integer() throws an exception when the string is not of the right format in a section titled something like "Turning strings into numbers". So it looks like those books would be good companion texts. -- Posted via http://www.ruby-forum.com/.