Kitty1911
Kitty1911

Reputation: 681

Creating instance variables in Ruby

This question is regarding programming practices in Ruby. Is it preferable to create instance variables in ruby inside a static method? Or should they be created in an initialize method?

Upvotes: 0

Views: 262

Answers (1)

Andrea
Andrea

Reputation: 26385

Well initialize is made for that, why would you do something different.

class SomeClass
  def initialize(first, second)
    @first     = first
    @second   = second
  end
end

Upvotes: 1

Related Questions