Type Inference in RubyMine
Friday, November 7th, 2008What is the one thing that some of us like and others dislike about dynamic languages such as Ruby? It is dynamic types of course! It is a blessing and a curse. And for an IDE that claims being a Ruby IDE it is a serious task. There is a lot an IDE can help developer when working with such extremely flexible type system as Ruby’s.
We think RubyMine is the leader here. And here is why.
Local Variables Type
if some_cond aaa = "string" else aaa = [1, 2, 3] end aaa. #at this point aaa is either string or array
RubyMine knows that aaa can be one of two types, so pressing Ctrl+Space for code completion shows the list of methods corresponding to possible types.

The “…” on the right means there are more than one variations.
To see the inferred types that RubyMine sees for the variable press Ctrl+Q/^ J for Quick documentation lookup.

If we choose include?(obj) and then press Ctrl+B/⌘ B for method definition, RubyMine will confirm whether to go to array.rb or to string.rb.
