Skip to content

Instantly share code, notes, and snippets.

@tejasInSiberia
Created June 12, 2020 19:12
Show Gist options
  • Save tejasInSiberia/71a4cf8442cab7e1b5bf1486ff4c5455 to your computer and use it in GitHub Desktop.
Save tejasInSiberia/71a4cf8442cab7e1b5bf1486ff4c5455 to your computer and use it in GitHub Desktop.
# Ruby program a private class accessed through the outer-class.
# public
class Marvel
# private
class Guardians
def Quill
puts "Legendary outlaw"
end
def Groot
puts "I am Groot"
end
# private_class_method :Groot
end
class Avengers
def Tony
puts "I am Iron-man"
end
end
# outer-class method accessing private classes
def fury
p "printed bro"
return Guardians.new
end
private_constant :Guardians
private_constant :Avengers
end
# calls fury method in Marvel call.
gotchaGurdian = Marvel.new.fury
gotchaGurdian.Groot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment