Skip to content

Instantly share code, notes, and snippets.

@harrisonmalone
Created March 4, 2020 06:17
Show Gist options
  • Save harrisonmalone/8347da1e0be46d13bcb73eff316fb9c8 to your computer and use it in GitHub Desktop.
Save harrisonmalone/8347da1e0be46d13bcb73eff316fb9c8 to your computer and use it in GitHub Desktop.
class Dog
attr_reader :name, :age, :breed # etc
def initialize(name, age, breed)
@name = name
@age = age
@breed = breed
end
def name
@name
end
def speak
puts "woof"
end
end
tilly = Dog.new("tilly", 4, "border collie")
# => instance of a class
tilly.speak
# => instance method being called
# getters
p tilly.name
# => tilly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment