WARNING: This blog entry was imported from my old blog on blogs.sun.com (which used different blogging software), so formatting and links may not be correct.
If you try code completion on any complicated arbitrary expression, it will show you a number of possible method completions along with the corresponding class. This gives you much the same information as ri:
However, in many contexts, we know the exact type. For example, if you type
File. and invoke code completion, NetBeans will show you only the singleton methods of class
File (as well as inherited methods and module mixins):
In some cases, we know more than just the class - we know that we're dealing with an instance of that object. In that case we can show all the instance methods too - not just the class methods:
Here's we're applying code completion on a regular expression literal.
This works for all kinds of literals in your code - Strings, regular expressions (shown above), arrays (try
[1,2,3].e to see the
each method and its documentation for example), hashes, symbols, numbers, ... you can even try it on the "nil" keyword!