I am having some struggle using rubocop and don't know how I could solve this problem.
The code I have:
class Test
@hello = 'stackoverflow'
def self.hello
@hello
end
end
p Test.hello
It runs the way i want, but when I run rubocop it says to use attr_reader. If I try to use attr_reader it gives me NoMethodError.
I already tried to solve this like this, but rubocop is still not happy.
class Test2
@hello = 'stackoverflow'
class << self
def hello
@hello
end
end
end
How could I solve this?