Skip to content

Latest commit

 

History

History
39 lines (19 loc) · 1.07 KB

classes.md

File metadata and controls

39 lines (19 loc) · 1.07 KB

Basics

  1. When would you think to create your own class?

  2. What's the difference between a class and an instance of a class?

  3. If you had an object called instructor and you wanted to find its name, what code should you probably write?

  4. What is the functional difference between a varible named hometown and a variable named @hometown?

  5. Assume you have a class named Car, with attributes of make, model and year. Write some code to create an instance of that class named new_car, then set the make of new_car to "Toyota"

  6. If the attr_accessor line of the following class were commented out, what code could you write to achieve the same functionality?

    class Student attr_acessor :name end

For later

  1. Assume you want to create a Class of student that has a default attribute of course that is set to 'web development'. What is wrong with the following code?

class Student @course = 'web development'

def list_course
  return @course
end

end

  1. What's the difference between a class level method and an instance level method