Skip to content

Instantly share code, notes, and snippets.

@geocodinglife
Last active March 23, 2017 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geocodinglife/7135f5e9a399137726c9817c3d196b43 to your computer and use it in GitHub Desktop.
Save geocodinglife/7135f5e9a399137726c9817c3d196b43 to your computer and use it in GitHub Desktop.
class Person
attr_reader :name
def initialize(name)
self.name = name
end
def name=(name)
if name == nil or name.size == 0
raise ArgumentError.new('Must have a name.')
end
@name = name
end
end
p Person.new("Pedro")
# p Person.new(nil)
# p Person.new("")
# person = Person.new("Juan")
# p person.name = "Pedro"
# p person = nil
# p person1 = ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment