title: Class method in Ruby (equivalent of static in JAVA)
body: <p>Folks, I am learning ruby and recently moved from JAVA. In JAVA I could make a member variable of a class static and that member variable would remain the same across instances of the class. How do I achieve the same in ruby. I did something like this in my ruby class:</p>
  
  <pre><code>class Baseclass
  
    @@wordshash
  
  end
  </code></pre>
  
  <p>This seems to serve the purpose so far while I am testing this, that is @@wordhash remains the same across instances of Baseclass. Is my understanding correct.</p>
  
  <p>Also, I wanted to have a member method in the class that is equivalent of a static method in JAVA(I do not require to have an instance of the class to access this). How can I do this? For example I want to have a method in the Baseclass like getwordshash() which returns @@wordshash and the user of that method should not have to make an instance of Baseclass().So something like this:</p>
  
  <pre><code>class Baseclass
  
    @@wordshash
  
    #static or class method
    def getwordhash()
      return @@wordshash
    end
  end
  </code></pre>
  
  <p>and then I can use it like</p>
  
  <pre><code>#without making an instance
  @hash = Baseclass.getwordhash()
  </code></pre>
  
  <p>I apologize if this is a very naive question, i am really new to ruby but very excited to learn.</p>