To call a public property on an instance of a class in Ruby, you can use the dot notation followed by the property name.
For instance:
main.rb221 chars14 lines
This code creates a Person
class with a public name
property and a constructor that sets the name
property. It then creates a new Person
instance and calls the name
property using the dot notation (person.name
). The name
property returns the name of the person, which is then printed to the console.
gistlibby LogSnag