'I am trying to set a new value to the singleton method that has already being defined in ruby but I could not find a proper method to do so
define_singleton_method(:node_name){ "NODE0003" }
=> :node_name
node_name
=> "NODE0003"
I tried to change this value using set_to method but gives the error
node_name.set_to("Node")
Traceback (most recent call last):
5: from /Users/kr018/.rbenv/versions/2.7.2/bin/irb:23:in `<main>'
4: from /Users/kr018/.rbenv/versions/2.7.2/bin/irb:23:in `load'
3: from /Users/kr018/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/irb-1.2.6/exe/irb:11:in `<top (required)>'
2: from (irb):54
1: from (irb):55:in `rescue in irb_binding'
NoMethodError (undefined method `set_to' for "NODE0003":String)
Could someone help on this ?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
