Vote count:
0
I'd like to use block in ruby within the initialize method .
class Settlement
attr_reader :url, :parameters
def initialize(&block)
instance_eval block.call
end
#initialize用
def parameters(x) ; @parameters = x; end
def url(x) ; @url = x; end
end
settlement = Settlement.new do
url "https://xxxxx"
parameters("ffff")
end
With this code, i got the below error message
NoMethodError - undefined method parameters
Any ideas ?
Thank you
asked 43 secs ago
Aucun commentaire:
Enregistrer un commentaire