Created
May 2, 2020 16:44
-
-
Save Oceantidote/6aac330292848b7b83576d8b2036126e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BareCitizen | |
# def initialize(name) | |
# @name = name | |
# end | |
def declare | |
puts "I AM #{@name}" | |
end | |
def name(name) | |
puts "I AM #{name}" | |
end | |
end | |
# better_citizen = BareCitizen.new("bob") | |
# other_citizen = BareCitizen.new("phil") | |
new_citizen = w | |
new_citizen.name("peter") | |
require "pry-byebug" | |
1.times do | |
binding.pry | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Citizen | |
attr_accessor :age | |
def initialize(first_name, last_name, age) | |
@first_name = first_name | |
@last_name = last_name | |
@age = age | |
end | |
def can_vote? | |
@age >= 18 | |
end | |
def full_name | |
f = @first_name.strip.capitalize | |
l = @last_name.strip.capitalize | |
"#{f} #{l}" | |
end | |
end | |
bob = Citizen.new("bob", "hope", 15) | |
bob.age = 40 | |
bob.age |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment