implement Person#to_proc to return a new Proc where the instance send its self the symbol where the symbol is a reader/accessor of an instance attribute:
class TestMe
attr_reader :to_proc, :test_me
def initialize(test_me_value)
@test_me = test_me_value
@to_proc = Proc.new {|sym| send(sym)}
end
end
t = [:test_me]
t0 = TestMe.new "hello from procified"
p t.map(&t0)
1 Like
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.