user93796
user93796

Reputation: 18389

Autocomplete in ruby mine

I am new to ruby and rubmine. I am trying to use ruby mine.

I have class as follows

module Xyz;
    class A
     def doA()
     end
    end 
end 

module Xyz
  class B
    def doB()
    end
  end
end


module Xyz 

 class C
   define initialize(b)
     #injecting instance of Xyz::B into C
     @b = b
   end
   def doC()
     a = Xyz::A.new 
     a.doA()  #Autocompletes workshere
     b.doB()  #Doesnot autocomplete, so suggestions shown
   end
 end 
end

Why is my autocomplete not working for doB() ? Am i doing something wrong?or is it expected?

Upvotes: 0

Views: 469

Answers (1)

Ruslan
Ruslan

Reputation: 2009

Look at this code:

class Test
   def initialize(a)
      @a = a
   end
end

Do you know what methods @a will have before it actually gets assigned and run? Ruby is truly duct typed language. RubyMine does a good job in indexing classes and predicting methods. For example this will work because Xyz has been indexed and RubyMine knows what methods it had, so it can predict it.

 a = Xyz::A.new 
 a.doA()  # Works because RubyMine KNOWS what class 'a' is

Upvotes: 1

Related Questions