Skip to content

Instantly share code, notes, and snippets.

@krokrob
Created January 14, 2016 10:32
Show Gist options
  • Save krokrob/56bd921b41d6b04c6d3c to your computer and use it in GitHub Desktop.
Save krokrob/56bd921b41d6b04c6d3c to your computer and use it in GitHub Desktop.
class Chief
attr_reader :name, :restaurant
def initialize(name, age, restaurant)
@name = name
@age = age
@restaurant = restaurant
end
end
class Restaurant
attr_reader :name, :chief
def initialize(name, city, chief_name, chief_age)
@name, @city = name, city
@chief = Chief.new(chief_name, chief_age, self)
end
def to_s
return "Welcome to #{@name}, in #{@city}"
end
end
mama = Restaurant.new("Mama Roma", "Paris", "Georges", 51)
georges = mama.chief
puts georges.restaurant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment