Answers for "difference between attr_reader and attr_accessor"

0

ruby attr_writer example

class Person
  attr_reader :name, :age, :sex, :email
  attr_writer :name, :age, :sex, :email

  def initialize(name)
    @name = name
  end
end
Posted by: Guest on May-29-2020
0

ruby attr_writer example

class Person
  attr_reader :name
  attr_writer :name

  def initialize(name)
    @name = name
  end
end

john = Person.new("John")
john.name = "Jim"
puts john.name # => Jim
Posted by: Guest on May-29-2020

Code answers related to "difference between attr_reader and attr_accessor"

Browse Popular Code Answers by Language