Skip to content

Ruby – generate attr_accessor for ivars #17

@atg

Description

@atg

Input

class Barney:
  def __init__(self):
    self.status = 'not ok'
barney = Barney()
barney.status = "ok"
print(barney.status)

Output

class Barney
  def initialize
    @status = 'not ok'
  end

end

barney = Barney.new
barney.status = 'ok'
puts barney.status

Error

undefined method status=' for #<Barney:0x007f837084d190 @status="not ok"> (NoMethodError)`

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions