Instance Variables

Learn about instance variables.

Now that we’ve learned how the string that we pass to the new method passes to the new object’s initialize method, we can start improving initialize. We want it to do something with the string and actually initialize our new object:

class Person
  def initialize(name)
    @name = name
  end
end

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy