From: Phillip Gawlowski Date: 2009-12-27T13:27:34+09:00 Subject: Re: How to truncate the spaces in the front of a line On 27.12.2009 05:20, Milo Luo wrote: > Thanks for great explainations. > And one more question, how can you get this method so quickly? Is that > your experience or is tip there on it? Both. ;) For one, experience allows me to remember where, roughly, something is in the documentation, or if something that I want to do exists already. Then it is down to reading the documentation. ;) Ruby is, for the most part, logically organized (once you now the lingo). In your example, you have a String (appending .class to anything should reveal the object's class, [].class reveals that this is an Array), so you look at what methods the String class offers. With a little experimentation in irb, you can see if what you found is useful. :) A few pointers: You can access Ruby's documentation online at ruby-doc.org. Another help is the excellent Pickaxe book (Programming Ruby, 2nd Edition is the most relevant for 1.8.x; 3rd Edition for Ruby 1.9.x), which works as a Ruby tutorial (for experienced developers, anyway), and an excellent reference to the language. -- Phillip Gawlowski